Ask a question

Shawn Lemay

Script to determine Windows 10 builds in domain?

Is there a script, that anyone is aware of, that I can run in PowerShell to have it either look in AD or scan the domain and report back all the different versions of Windows 10 that are in my network? I came across a few sites and discovered that some workstations aren't getting upgraded to the latest builds. I tried searching for this, but can't find anything.

Thanks.


asked03/24/2019 22:28
106 views
Add Comment
Mariette Knap

Microsoft MVP

Try this

Get-CimInstance Win32_Operatingsystem -ComputerName xyz | select -expand Version

The above will show the version of the OS for the Computer name you enter. If we need to do that for multiple computers we have to do this

Start-Transcript c:\OSversion.txt
foreach($computer in $computers)
{
    Invoke-Command -ComputerName $computer -ScriptBlock {

         $env:computername
         Get-CimInstance Win32_Operatingsystem | select -expand Version

    }
}
Stop-Transcript

I have not tested the above but give it a try

Shawn Lemay

I get an error:

Transcript started, output file is c:\OSversion.txt
PS C:\Users\ST-Admin> foreach($computer in $computers)
Missing statement body in foreach loop.
>> foreach($computer in $computers)
{
    Invoke-Command -ComputerName $computer -ScriptBlock {
Missing closing '}' in statement block or type definition.
>> foreach($computer in $computers)
{
    Invoke-Command -ComputerName $computer -ScriptBlock {
         $env:computername
         Get-CimInstance Win32_Operatingsystem | select -expand Version
Missing closing '}' in statement block or type definition.
>> foreach($computer in $computers)
{
    Invoke-Command -ComputerName $computer -ScriptBlock {
         $env:computername
         Get-CimInstance Win32_Operatingsystem | select -expand Version
    }
}
Stop-Transcript


replied 03/25/2019 13:15
Last Activity 03/25/2019 13:15

No answers found

Add an Answer