Questions

Forum Navigation
Please to create posts and topics.

Powershell - Change Output Object Property Names

How to change the "Label" or "Name" of a property selected by using Select or Select-Object in Powershell?

Let's say we want to get some info from WMI our computer name by using Powershell: the easiest way to achieve this is to use Select-Object and a calculated field:

Get-WmiObject -Class win32_OperatingSystem -ComputerName webr201 | Select-Object @{N='ComputerName'; E={$_.PSComputerName}}

In this way we will be able to rename the selected label/name by using, as we said above, a calculated field (in which, however, we did not calculate anything).