October 10th, 2013

PowerTip: Change Output Object Property Names with PowerShell

Doctor Scripto
Scripter

Summary: Use Windows PowerShell to change output object property names.

Hey, Scripting Guy! Question How can I use Windows PowerShell to change the property names of my output objects?

Hey, Scripting Guy! Answer The easiest way to achieve this to use Select-Object and a calculated field:

Get-WmiObject -Class win32_OperatingSystem -ComputerName webr201 |

select @{N=’ComputerName’; E={$_.PSComputerName}},

@{N=’OS’; E={$_.caption}},

@{N=’SP’; E={$_.ServicePackMajorVersion}}

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.

Feedback