Invoke-Command w/ Get-Clipboard

Topics: User Forum
Dec 11, 2014 at 9:04 AM
Edited Dec 12, 2014 at 8:05 AM
This is probably more of a powershell question than PSCX. I know the following command works:
Invoke-Command -ComputerName (Get-Content Machines.txt) -ScriptBlock {(Get-Host).Version}

Atleast it should because I pulled it from get-help invoke-command. But if I copy those same machines to the clipboard and issue the following command, why doesn't this work?

Invoke-Command -ComputerName (Get-Clipboard | Split-String -NewLine) -ScriptBlock {Get-Service -Name Spooler}

Jan 11, 2015 at 6:32 AM
Hmm, I can't repro the problem. It probably depends on the format of the text in clipboard.