Freigeben über


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

  • Anonymous
    August 12, 2010
    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 techibee.com/.../689

  • Anonymous
    May 03, 2012
    (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.

  • Anonymous
    November 01, 2012
    "(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.

  • Anonymous
    April 23, 2013
    I found .OSArchitecture also is null on X64 Win2003, so relying on null is not indication of 32bit unfortunately.

  • Anonymous
    May 02, 2013
    For XP/2K3 OS's use (Get-WmiObject -Class Win32_Processor).addresswidth to obtain the machine architecture.

  • Anonymous
    August 05, 2014
    The commands worked for me.  Thank you for your knowledge!

  • Anonymous
    September 07, 2014
    For information regarding a remote system use: $name=SYSTEM_NAME (Get-WmiObject Win32_OperatingSystem -ComputerName $name).SerialNumber

  • Anonymous
    December 16, 2014
    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 Regards Raj Navalgund

  • Anonymous
    March 06, 2015
    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

  • Anonymous
    September 24, 2015
    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)

  • Anonymous
    December 22, 2015
    wahat about Server 2003 versus Server 2003 R2 ... it still says Server 2003 ...