PowerShell Script to Find OS of Multiple Computers

PowerShell Script to Find OS of Multiple Computers

How To Get Operating System Details Using PowerShell

Enterprises with thousands of computers can be hard to manage, especially when the computers are running different versions of a operating system. As administrators want to upgrade computer OS's that are phased out, but still operating, it can be difficult spotting which exact computer is running which operating system. 

Microsoft has provided some solutions to this challenge, such as PowerShell and some other scripts that will query each computer and report back what the current operating system is. Here's how you can check the OS versions that all computers in your environment are running. 

Open up a PowerShell cmd window and enter the following command:
Get-ADComputer -Filter * -Property * | Format-Table Name,OperatingSystem,OperatingSystemServicePack,OperatingSystemVersion -Wrap –Auto
This command is filtering all computers for all their properties. It then redirects the output into a formatted table. The only attributes that the table contains are the computer name, operating system description, service pack, and OS version. It also automatically sizes and wraps the data.

In order to find all servers in the domain, run the following command:
Get-ADComputer -Filter {OperatingSystem -Like "Windows Server*"} -Property * | Format-Table Name,OperatingSystem,OperatingSystemServicePack -Wrap -Auto
In order to find all servers running Windows Server 2008, run:
Get-ADComputer -Filter {OperatingSystem -Like "Windows Server*2008*"} -Property * | Format-Table Name,OperatingSystem,OperatingSystemServicePack -Wrap -Auto
In order to find all servers running Windows Server 2008 R2, run:
Get-ADComputer -Filter {OperatingSystem -Like "Windows Server*r2*"} -Property * | Format-Tab
These cmdlets return a CSV that contains a list of all the computers or servers running which version of the operating system. 

    • Related Articles

    • PowerShell Remoting: Accessing Remote Computers with Precision

      In today's interconnected IT environments, managing remote computers is an essential task for system administrators. PowerShell Remoting, a powerful feature of Windows PowerShell, allows administrators to access and control remote machines ...
    • LAPS - Manage Local Administrator Passwords on Domain Computers

      What is Local Administrator Password Solution (LAPS)? The Local Administrator Password Solution, generally abbreviated as LAPS, is a tool developed by Microsoft to manage local administrator passwords on Windows computers. Since the local ...
    • Finding AD Users with No Logon Script Using PowerShell

      PowerShell Script to Find Users with No Logon Script Login scripts failing to configure is one of the most commonly seen errors when user accounts are provisioned in Active DirectoryThis is especially true when user accounts are provisioned in ...
    • PowerShell: Find and Delete Empty Groups in Active Directory

      Cleanup Empty AD Groups with PowerShell Administrators turn to groups to grant a set of users permissions and access rights to resources. However, once the work is done and the resources are no longer needed, the users are removed from the group, ...
    • How to Update GPOs on Remote Computers

      Updating GPOs On Remote Computers Group Policy Objects can be added or modified by the administrator according to the requirements of the organization. Generally, the time taken for a new Group Policy Object (GPO) to be applied is between 90 and 120 ...