PowerShell v3 Test Memory Architecture

Three simple functions I saw the basis of a few ways back. Nothing special. Just good for reference. To test if a system is x86, run this:
function Isx86
{
      switch([IntPtr]::Size)
      {
            4
            {
                  $true
            }
            8
            {
                  $false
            }
      }
}
To test if a system is x64, use this approach:
function Isx64
{
      switch([IntPtr]::Size)
      {
            4
            {
                  $false
            }
            8
            {
                  $true
            }
      }
}
Another way to approach it:
function Get-ProcessorBitWidth
{
      switch([IntPtr]::Size)
      {
            2
            {
                  return 16
            }
            4
            {
                  return 32
            }
            8
            {
                  return 64
            }
      }
}
Much more complex tricks can be done, but, these are good to know about.

Related Posts by Categories

0 comments:

Post a Comment