Q. Why can't Invoke-Command accept computer names from the pipeline?

Don Jones

June 6, 2010

1 Min Read
ITPro Today logo in a gray background | ITPro Today

A. The Help file for the Invoke-Command cmdlet indicates that the -computerName parameter accepts pipeline input through ByPropertyName. This suggests that you can pipe in an object that contains a "computername" property and have that property "attach" to the -computerName parameter. Sadly, as near as I can figure out, it doesn't actually work, which seems to be an oversight on Microsoft's part. The -inputObject parameter of Invoke-Command binds any pipeline input of type "object" ByValue. The ByValue binding always happens first, and everything is a generic "object." In other words, the -inputObject parameter snatches up any pipeline input before -computerName gets a chance to see it.

 

Do you have a Windows PowerShell question? Why not submit it to Don? Post your question at www.windowsitpro.com/FAQs/FAQSubmittalForm.aspx and you might see your answer online! Find more PowerShell FAQs, articles, and other resources at windowsitpro.com/go/DonJonesPowerShell.

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like