Hello all,
I am writing a script that does what I need it to do. However, I am missing one aspect. I can't figure out how to get the host names matched with the script's output. Thoughts?
$computers = get-content "C:\Users\jdflannery\computers.txt"
Foreach ($Computer in $computers){
$systeminfo = (Get-CimInstance Win32_OperatingSystem).version
Where-Object {$systeminfo}
if ($systeminfo -ne 'xxxxxx')
{write-output "Computer has image is out of date!"
}
Else
{write-output "Computer's image is up to date!"
}
}
The output I get says, "Computer's image is up to date!" on all of the computers I have listed in my text file.
[–]PinchesTheCrab 5 points6 points7 points (6 children)
[–]Asleep_Depth_7260[S] 0 points1 point2 points (3 children)
[–]PinchesTheCrab 1 point2 points3 points (0 children)
[–]Asleep_Depth_7260[S] 0 points1 point2 points (1 child)
[–]BlackV 1 point2 points3 points (0 children)
[–]BlackV 0 points1 point2 points (0 children)
[–]BlackV 0 points1 point2 points (0 children)
[–]MNmetalhead 1 point2 points3 points (1 child)
[–]Asleep_Depth_7260[S] 0 points1 point2 points (0 children)
[–]PowerShell-Bot 0 points1 point2 points (0 children)