I want to get serial numbers of remote PC's with the name of PC, in one table. $PCNameArray is array of remote PC I want to get serial numbers.
$complete = $false
$arrayJobs = @()
Foreach($a in $PCNameArray) {
$arrayJobs += Get-WmiObject -ComputerName $a -Class Win32_BIOS -asjob
}
while (-not $complete) {
$arrayJobsInProgress = $arrayJobs |
Where-Object { $_.State -match ‘running’ }
if (-not $arrayJobsInProgress) { “All Jobs Have Completed” ; $complete = $true }
}
$arrayJobs | Receive-Job
this code will give me only serial numbers. How can I add each PC names to this result? Thank you.
The computer name is returned as a property of the returned WMI object, it's just not shown by default. You can show it like this:
This gives output like this:
PsComputerName
is added to the WMI object by PowerShell, but the object itself has a__Server
property that also contains the computer name. You can see everything that is returned by replacingFormat-Table PsComputerName, SerialNumber -AutoSize
in the above example withFormat-List *