1

This script is working fine to get the OS version. I need to know who to get only Microsoft Windows 10 Pro in the result

$Computers = Get-Content C:\computerlist

Foreach($Computer in $Computers)
{ 


Get-WmiObject Win32_OperatingSystem -ComputerName $Computer -ErrorAction  SilentlyContinue | Select-Object CSName, Caption | sort CSName


}

2 Answers 2

2

I'm not sure if I understandy you correctly, but I think you need Where-Object:

$Computers = Get-Content C:\computerlist

Foreach($Computer in $Computers)
{ 
  Get-WmiObject Win32_OperatingSystem -ComputerName $Computer -ErrorAction  SilentlyContinue | Select-Object CSName, Caption | where Caption -eq "Microsoft Windows 10 Pro" | sort CSName
}
Sign up to request clarification or add additional context in comments.

1 Comment

Yes that what i need to accomplish thanks Ocaso. I'm sorry my english is bad.
0

If you want just the Caption value, use Select-Object -ExpandProperty Caption:

foreach($Computer in $Computers)
{
    Get-WmiObject Win32_OperatingSystem -ComputerName $Computer -ErrorAction  SilentlyContinue | Select-Object -ExpandProperty Caption
}

1 Comment

maybe i didn't explain my self correctly sorry for my bad english. What i'm trying to accomplish with this powershell is to find what computer are using window 10 i don't want all the windows 7 and 8 in the result but just the windows 10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.