PowerShell – How to find details of Operating System

There were several instances where I had to find details of the operating system using PowerShell. Here, I am providing several PowerShell snippets that return various details of the Operating System.

Name of the Operating System

PS C:\> (Get-WmiObject Win32_OperatingSystem).Name

Is Operating System 32-bit or 64-bit

PS C:\> (Get-WmiObject Win32_OperatingSystem).OSArchitecture

Name of the Machine

PS C:\> (Get-WmiObject Win32_OperatingSystem).CSName

There are many more properties of the Operating System that are exposed. To obtain more details, run the following

PS C:\> Get-WmiObject Win32_OperatingSystem | Get-Member

* Tested using PowerShell 2.0

Comments (11)

  1. Sitaram says:

    The above query will not help you in querying the OS architecture for windows 7/2008 operating systems. You need to rely on "caption" attribute value for this.

    (Get-WmiObject Win32_OperatingSystem).caption


  2. rlinhartpdx says:

    (Get-WmiObject Win32_OperatingSystem).OSArchitecture returns null when I run it on my Windows XP SP3 but returns '64-bit' when I run it on Windows 7.

  3. AJ says:

    "(Get-WmiObject Win32_OperatingSystem).OSArchitecture returns null when I run it on my Windows XP SP3 but returns '64-bit' when I run it on Windows 7."

    Since WMI has its own database, it performs a query on data that exists. Since windows XP (at first) was only 32-bit, there was no reason to define it as 32-bit. Later operating systems came in different architectures and therefore had to be defined in the WMI database with the Os Architecture column in that specific table. if the value comes back as null, you will know that it is indeed 32-bit. If it comes back with a value at all, it is most likely a 64bit XP machine.

  4. I found .OSArchitecture also is null on X64 Win2003, so relying on null is not indication of 32bit unfortunately.

  5. Walshy says:

    For XP/2K3 OS's use

    (Get-WmiObject -Class Win32_Processor).addresswidth

    to obtain the machine architecture.

  6. bakerjo says:

    The commands worked for me.  Thank you for your knowledge!

  7. ofrazier says:

    For information regarding a remote system use:


    (Get-WmiObject Win32_OperatingSystem -ComputerName $name).SerialNumber

  8. Raj Navalgund says:

    Hi Kotesh,

    Please let me know how to pull the name of the operating system either using list if IP's (IPlist.txt) or List of hostname.(Hostnames.txt


    Raj Navalgund

  9. Rick Perez says:

    You can also get a neat result if you include the "Format-Table command…..

    Get-WmiObject Win32_OperatingSystem -ComputerName WHATEVERCOMPUTERNAME | Format-Table

    csname, caption,OSArchitecture,ServicePackMajorVersion -AutoSize

  10. Anonymous says:

    You can also determine if it is a workstation, server or domain controller.

    (Get-WmiObject Win32_OperatingSystem).ProductType

    Work Station (1)

    Domain Controller (2)

    Server (3)

  11. Chris says:

    wahat about Server 2003 versus Server 2003 R2 … it still says Server 2003 …

Skip to main content