D.chan D.chan - 1 year ago 122
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

Answer Source
select @{l='drives';e='DeviceID'}, @{l='server';e='SystemName'}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download