Hi,
I have this string that half works.
i am unable to sting together to get the .config and .guest and .guest.net all in one command string.
any suggestions.
> Get-VM -name "System1" | Sort | Get-View -Property @("Name", "Config.ChangeVersion", "guest.guestfullname", "Guest.hostname", "guest.ipaddress", "guest.gueststate", "guest.net.network") | Select -Property Name, @{N="ChangeVersion";E={$_.Config.ChangeVersion}}, @{N="Running OS";E={$_.Guest.GuestFullName}}, @{N="Hostname";E={$_.Guest.hostname}}, @{N="IP Address";E={$_.Guest.ipaddress}}, @{N="State";E={$_.Guest.gueststate}}, @{N="Network";E={$_.Guest.net.network}} | Format-Table -AutoSize
it should give me screen output of: but only give first three fields.
Name | ChangeVersion | Running OS | Hostname IP Address State Network |
---- | ------------- | ---------- | -------- ---------- ----- ------- |
System1 2019-03-13T16:46:29.301502Z Microsoft Windows Server 2016 (64-bit)
goal to get
name, changeVersion, guestfullname, hostname, ipaddress, gueststate, guest.net.network
thanks.
The problem is with the last property.
Since Guest.Net is an array, you not do Guest.Net Network.
But that is no issue do display the Network values in a calculated property with the -join operator
sort |
Get-View -Property "Name", "Config.ChangeVersion", "guest.guestfullname", "Guest.hostname", "guest.ipaddress", "guest.gueststate", "guest.net" |
select -Property Name, @{N = "ChangeVersion"; E = { $_.Config.ChangeVersion } },
@{N = "Running OS"; E = { $_.Guest.GuestFullName } },
@{N = "Hostname"; E = { $_.Guest.hostname } },
@{N = "IP Address"; E = { $_.Guest.ipaddress } },
@{N = "State"; E = { $_.Guest.gueststate } },
@{N = "Network"; E = { $_.Guest.net.network -join '|' } } |
Format-Table -AutoSize
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The problem is with the last property.
Since Guest.Net is an array, you not do Guest.Net Network.
But that is no issue do display the Network values in a calculated property with the -join operator
sort |
Get-View -Property "Name", "Config.ChangeVersion", "guest.guestfullname", "Guest.hostname", "guest.ipaddress", "guest.gueststate", "guest.net" |
select -Property Name, @{N = "ChangeVersion"; E = { $_.Config.ChangeVersion } },
@{N = "Running OS"; E = { $_.Guest.GuestFullName } },
@{N = "Hostname"; E = { $_.Guest.hostname } },
@{N = "IP Address"; E = { $_.Guest.ipaddress } },
@{N = "State"; E = { $_.Guest.gueststate } },
@{N = "Network"; E = { $_.Guest.net.network -join '|' } } |
Format-Table -AutoSize
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference