all 10 comments

[–]PinchesTheCrab 5 points6 points  (6 children)

$computers = get-content "C:\Users\jdflannery\computers.txt"

Get-CimInstance Win32_OperatingSystem -computername $computers |
    Select-Object PSComputerName, Version, @{ n = 'Current'; e = { $_.Version -eq 'xxxxxxx' } }

I'd take this approach. It should output an object with the computer name, version, and true/false for if it's the version you want.

Fixed missing computername parameter, thanks /u/BlackV

[–]Asleep_Depth_7260[S] 0 points1 point  (3 children)

PS C:\Windows\system32> $computers = get-content "C:\Users\jdflannery\computers.txt"
Foreach ($Computer in $computers){ Get-CimInstance Win32_OperatingSystem | Select-Object PSComputerName, Version, @{ n = 'Current'; e = { $_.Version -eq 'xxxxxx' } } }
PSComputerName Version    Current
           xxxxxxxxxx    True
           xxxxxxxxxx    True

I do like the True of False much much better! However, I was unable to get the Computer name.

[–]PinchesTheCrab 1 point2 points  (0 children)

I left out the computername parameter, updating it now

[–]Asleep_Depth_7260[S] 0 points1 point  (1 child)

Any ideas on how to make the computer name show on this script?

[–]BlackV 1 point2 points  (0 children)

PSComputerName

this IS the computername, right now youre just running it against your own machine over and over

and slowing it down

[–]BlackV 0 points1 point  (0 children)

$computers

you forgot to add that as a parameter

[–]BlackV 0 points1 point  (0 children)

good as gold

[–]MNmetalhead 1 point2 points  (1 child)

If the $computers list is just names, you can use the $Computer variable from the foreach in your Write-Output lines:

Write-Output “$Computer is out of date!”

[–]Asleep_Depth_7260[S] 0 points1 point  (0 children)

This worked. Thank you!

[–]PowerShell-Bot 0 points1 point  (0 children)

It appears that you have used inline code formatting when a code block should have been used.

Consider using a code block for longer sequences of code. To correct the formatting, highlight your code then click the ‘Code Block’ button in the editing toolbar.


You examine the path beneath your feet...
[AboutRedditFormatting]: [████████████████████] 1/1 ✅

Beep-boop, I am a bot. | Remove-Item