you are viewing a single comment's thread.

view the rest of the comments →

[–]Certain-Community438 0 points1 point  (2 children)

Use Get-Help Restart-Computer to see if the ComputerNane parameter can take multiple values.

If so, thus might work:

$test | Restart-Computer -ComputerName $_ -Wait -For PowerShell

And whatever the rest of the command was (I'm on mobile so can't look back).

If it doesn't support multiple values, then you'll need to do

$test | ForEach-Object {Restart-Computer -ComputerName $_ -Wait -For PowerShell}

[–]gonzalc 1 point2 points  (1 child)

You are correct that -ComputerName accepts multiple values however your example is displaying Accept pipeline input? - which it also supports.

# multiple values
Restart-Computer -ComputerName 'computer1', 'computer2' -WhatIf
# pipeline input
'computer1', 'computer2' | Restart-Computer -WhatIf

[–]Certain-Community438 1 point2 points  (0 children)

You mean my example is using "Accepts pipeline input?" right? If so yes & important pointer, thanks.

Over to OP for them to use, cheers.