Using the example below:
Get-Service | ConvertTo-HTML -Property Name, Status > C:\\services.htm
I was wondering if it is possible to ali
You could do an intermediate step of creating objects with the property names you want using the new-object
cmdlet.
Get-Service | foreach{ new-object PSObject -property @{newname=($_.Name); newstatus=($_.Status)}} | ConvertTo-Html > .\services.htm
How about using select-object?
get-service | select-object -property @{N='MyNewStatus';E={$_.Status}}, @{N='MyNewName';E={$_.Name}} | ConvertTo-HTML > C:\services.htm
The way to alias a property name is to add an AliasPropery to the object.
Get-Service |
foreach {
$_ | Add-Member -MemberType AliasProperty -Name MYNEWSTATUSNAME -Value Status -PassThru
} |
Select Name,MYNEWSTATUSNAME