PowerTip: Change Output Object Property Names with PowerShell

Doctor Scripto

Dr Scripto

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}}

Doctor Scripto
Dr Scripto

Scripter, PowerShell, vbScript, BAT, CMD

Follow Dr Scripto   

0 comments

    Leave a comment