Automation

 View Only
  • 1.  vcenter vm lable Vs dns name

    Posted Sep 12, 2016 10:05 PM

    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



  • 2.  RE: vcenter vm lable Vs dns name

    Posted Sep 12, 2016 11:00 PM

    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



  • 3.  RE: vcenter vm lable Vs dns name
    Best Answer

    Posted Sep 13, 2016 04:43 AM

    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}}