确定当前的 PowerShell 进程是 32 位还是 64 位? [英] Determine if current PowerShell Process is 32-bit or 64-bit?

查看:28
本文介绍了确定当前的 PowerShell 进程是 32 位还是 64 位?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 x64 位操作系统平台上运行 PowerShell 脚本时,如何确定在脚本中该脚本在哪个版本的 PowerShell(32 位或 64 位)上运行?

When running a PowerShell script on a x64-bit OS platform, how can you determine in the script what version of PowerShell (32-bit or 64-bit) the script is running on?

背景
默认情况下,32 位和 64 位版本的 PowerShell 都安装在 64 位平台(例如 Windows Server 2008)上.这可能会导致在运行 PowerShell 脚本时必须针对特定体系结构(即使用 64 位用于 SharePoint 2010 的脚本,以便使用 64 位库).

Background
Both 32-bit and 64-bit versions of PowerShell are installed by default on a 64-bit platform such as Windows Server 2008. This can lead to difficulties when a PowerShell script is ran that must target a specific architecture (i.e. using 64-bit for a script for SharePoint 2010, in order to consume the 64-bit libraries).

相关问题:

  • What is the best way to program against powershell's x64 vs. x86 variability? This question deals with code running against both 32-bit and 64-bit architectures. My question deals with the case when you want to ensure the script only runs against the correct version.

推荐答案

如果您的 shell 在 .NET 4.0 (PowerShell 3.0) 上运行:

If you're shell is running on .NET 4.0 (PowerShell 3.0):

PS> [Environment]::Is64BitProcess
True

这篇关于确定当前的 PowerShell 进程是 32 位还是 64 位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆