I am trying to understand how to pipe |
an object and call the properties or methods on that.
Ex:
$a = Get-Item Registry::HKLM\SOFTWARE\WOW6432Node\Microsoft\Test\abc\
$a.GetSomething() //calls the method
(Get-Item Registry::HKLM\SOFTWARE\WOW6432Node\Microsoft\Test\abc\).GetSomething() //calls the method
Can I pipe the output of the Get-Item
and invoke properties/methods
on it?
Get-Item Registry::HKLM\SOFTWARE\WOW6432Node\Microsoft\Test\abc\ | call GetSomething()
The short answer is no. You can't call a method like this using Pipeline. But you can surround your Get-Item
invoke in parentheses and invoke it:
(Get-Item Registry::HKLM\SOFTWARE\WOW6432Node\Microsoft\Test\abc\).GetSomething()
If you don't want that, you could abuse the Select-Object
cmdlet:
Get-Item Registry::HKLM\SOFTWARE\WOW6432Node\Microsoft\Test\abc\ | select { $_.GetSomething() }