Hi everyone,
Can someone help me complete this script... We wanted to get additional information to list the network cards, network type, ip address and mac address. Thanks in advance.
Get-View -ViewType virtualmachine -SearchRoot (get-cluster 'testt').id -Filter @{'Summary.Guest.ToolsVersionStatus'='guestToolsNeedUpgrade'} |
Select Name,@{N='tools ver';E={$_.Config.Tools.ToolsVersion}},
@{N='Tools Status';E={$_.Summary.Guest.ToolsVersionStatus}},
@{N='Guest OS';E={$_.Config.GuestFullName}}
@{N='VM Notes';E={$_.Summary.Config.Annotation}},
@{N="Contact";E={
$key = $_.AvailableField | where {$_.Name -eq "Contact"} | Select -ExpandProperty Key
$_.CustomValue | where {$_.Key -eq $key} | Select -ExpandProperty Value}},
@{N="CreatedBy";E={
$key = $_.AvailableField | where {$_.Name -eq "CreatedBy"} | Select -ExpandProperty Key
$_.CustomValue | where {$_.Key -eq $key} | Select -ExpandProperty Value}},
@{N="CreatedOn";E={
$key = $_.AvailableField | where {$_.Name -eq "CreatedOn"} | Select -ExpandProperty Key
$_.CustomValue | where {$_.Key -eq $key} | Select -ExpandProperty Value}}|
Export-Csv -NoTypeInformation -UseCulture -Path C:\test\test1.csv
The following script should take care of collecting that information:
{code}
Get-View -ViewType virtualmachine -SearchRoot (get-cluster '*testt*').id -Filter @{'Summary.Guest.ToolsVersionStatus'='guestToolsNeedUpgrade'} |
Select Name,@{N='tools ver';E={$_.Config.Tools.ToolsVersion}},
@{N='Tools Status';E={$_.Summary.Guest.ToolsVersionStatus}},
@{N='Guest OS';E={$_.Config.GuestFullName}},
@{N='VM Notes';E={$_.Summary.Config.Annotation}},
@{N="vNIC Type";E={((Get-VM $_.Name).NetworkAdapters).Type}},
@{N="PortGroup";E={((Get-VM $_.Name).NetworkAdapters).NetworkName}},
@{N="MAC";E={((Get-VM $_.Name).NetworkAdapters).MacAddress}},
@{N="IP";E={$_.Summary.Guest.IpAddress}},
@{N="Contact";E={$key = $_.AvailableField | where {$_.Name -eq "Contact"} | Select -ExpandProperty Key $_.CustomValue | where {$_.Key -eq $key} | Select -ExpandProperty Value}},
@{N="CreatedBy";E={$key = $_.AvailableField | where {$_.Name -eq "CreatedBy"} | Select -ExpandProperty Key $_.CustomValue | where {$_.Key -eq $key} | Select -ExpandProperty Value}},
@{N="CreatedOn";E={$key = $_.AvailableField | where {$_.Name -eq "CreatedOn"} | Select -ExpandProperty Key $_.CustomValue | where {$_.Key -eq $key} | Select -ExpandProperty Value}} |
Export-Csv -NoTypeInformation -UseCulture -Path C:\test\test1.csv
{code}
Hi Mate,
I got a warning message the network adapters property of a virtual machine type is deprecated. use get network adapter cmdlet instead.
I also noticed that its taking a long time to finish. Is there any other commands?