This is the Powershell script I wrote:
$varCompList = Get-ADComputer -Filter "Name -like '*Name of Computers*'" -Properties OperatingSystemVersion | select DNSHostName, OperatingSystemVersion
foreach ($System in $varCompList){
$Restult=switch ($System.OperatingSystemVersion){
"10.0 (20348)"{"Server 2022"}
"10.0 (19042)"{"Server 2019 20H2"}
"10.0 (18363)"{"Server 2019 1909"}
"10.0 (17763)"{"Server 2019 1809"}
"10.0 (14393)"{"Server 2016"}
}
}
echo $varCompList
It displays all the Servers like it should but the OperatingSystemVersion is still displayed as 10.0 (14393).
What am I missing?
$Restultis assigned but never used, later only$varCompListis printed. Is that a copy-paste error?$Resultisn't used but I have no idea where to put it. If Iechothe$Result, it'll only show the version of my own PC/Server this script runs on. I'd somehow have to combine those.$Restult=with$System.OperatingSystemVersion=