While doing server inventory i found that a vm has vcenter lable & dns name mis-match. ideally they should be same to avoid confion.
Can with powercli we can find such mis-matched records
thanks
Try like this
Note that I added a test to check if $_.guest.hostname is not empty.
Get-View -ViewType "VirtualMachine" -Property @("Name", "guest.hostname", "config.name") |`
Where-Object {$_.guest.hostname -and ($_.guest.hostname.Split('.')[0] -ne $_.config.name) }|`
Select-Object -Property Name, @{N="DNS name";E={$_.guest.hostname}}, @{N="Configured OS name";E={$_.config.name}}
If you also want to list the VMs where $_.guest.hostname is empty (powered off, VMware Tools not installed...), you can do
Get-View -ViewType "VirtualMachine" -Property @("Name", "guest.hostname", "config.name") |`
Where-Object {!$_.guest.hostname -or ($_.guest.hostname -and ($_.guest.hostname.Split('.')[0] -ne $_.config.name))}|`
Select-Object -Property Name, @{N="DNS name";E={$_.guest.hostname}}, @{N="Configured OS name";E={$_.config.name}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
i did this
Get-View -ViewType "VirtualMachine" -Property @("Name", "guest.hostname", "config.name") |`
Where-Object {($_.guest.hostname -ne $_.config.name) }|`
Select-Object -Property Name, @{N="DNS name";E={$_.guest.hostname}}, @{N="Configured OS name";E={$_.config.name}}
problem is the dns name for unix is with FQDN vs the lable being without fqdn .. can we sort this somehow
Try like this
Note that I added a test to check if $_.guest.hostname is not empty.
Get-View -ViewType "VirtualMachine" -Property @("Name", "guest.hostname", "config.name") |`
Where-Object {$_.guest.hostname -and ($_.guest.hostname.Split('.')[0] -ne $_.config.name) }|`
Select-Object -Property Name, @{N="DNS name";E={$_.guest.hostname}}, @{N="Configured OS name";E={$_.config.name}}
If you also want to list the VMs where $_.guest.hostname is empty (powered off, VMware Tools not installed...), you can do
Get-View -ViewType "VirtualMachine" -Property @("Name", "guest.hostname", "config.name") |`
Where-Object {!$_.guest.hostname -or ($_.guest.hostname -and ($_.guest.hostname.Split('.')[0] -ne $_.config.name))}|`
Select-Object -Property Name, @{N="DNS name";E={$_.guest.hostname}}, @{N="Configured OS name";E={$_.config.name}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference