I'm trying to get the OS version of a selection of the computers on my domain. I created a powershell command that does this but it is missing the computer name on the output.
This is the command
Get-ADComputer -Filter {name -Like "test"} | select "name" | foreach {$_.name} {Get-WmiObject -Class Win32_OperatingSystem -ComputerName $_.name} | Select-Object Description, Caption,SevicePackMajorVersion | out-gridview
I've tried adding addtional select-objects but they are all blank. I'm thinking this is because this wmiobject simply doesn't contain the machine name.
So my question is, as I'm piping in the name with $_.name
is it possible it can be part of the output as well. I've tried using variations of ($_.name)
in the select-object command but to no avail.