D.chan D.chan - 10 months ago 75
PowerShell Question

PowerShell "select as" function on variable

This is just a simple question regarding alias issue on PowerShell syntax. Yet I can't find any related solution to it ATM.

Select SystemName , DeviceID,

From the above statement, I would like to display

"DeviceID" as "drives"


"SystemName" as "server"

Whole PowerShell script for ref:

$diskvalue += Get-WmiObject @Params | Select SystemName , DeviceID, @{Name=”size(MB)”;Expression={“{0:N1}” -f($_.size/1mb)}}, @{Name=”freespace(MB)”;Expression={“{0:N1}” -f($_.freespace/1mb)}}, @{Name=”UsedSpace(MB)”;Expression={“{0:N2}” -f(($_.size - $_.FreeSpace)/1mb)}}
$diskvalue | Export-Csv C:\example.csv -NoTypeInformation

select @{l='drives';e='DeviceID'}, @{l='server';e='SystemName'}