msgbartop
Everybody get your shell on!
msgbarbottom

Determining if you are running in the x86 or x64 Powershell console

If you have ever played with powershell on Windows 2008 64-bit, you are no doubt aware that there are two powershell consoles installed…the 32-bit version and the 64-bit version. This is to provide legacy support for scripts and applications that are only compatible with one version or another. If you are running the console by hand its pretty obvious if you are running the x86 or x64 version of the shell (the 64-bit version says Windows Powershell in the title, the 32-bit version says Windows Powershell x86). However, there may be times that you are delegating jobs to others that may require them to run scripts that need to run in one version or another. This handy piece of code determines if the powershell process is 32 or 64-bit and returns the version based on where the powershell process for that shell is located.

1
2
3
4
5
6
7
8
9
10
$Process = [diagnostics.process]::GetCurrentProcess()
 
If ($Process.Path -match '\\syswow64\\')
{
$Architecture = "32-Bit"
}
Else
{
$Architecture = "64-bit"
}


powershell32bit.jpg


powershell64bit.jpg

  • Twitter
  • Facebook
  • LinkedIn
  • Digg
  • Google Bookmarks
  • Slashdot
  • StumbleUpon
  • Live
  • FriendFeed
  • Ping.fm
  • Print
  • email
  • PDF
  • RSS

Tags:

Leave a Comment