Q. Why can't Invoke-Command accept computer names from the pipeline?Q. Why can't Invoke-Command accept computer names from the pipeline?
June 6, 2010
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.
About the Author
You May Also Like