Finding the host where your VM resides

yotube
0
It seems funny but possible, where using virtual vCenter and didn't created any VM-host affinity rule to limit its movement on hosts and in case if vCenter goes down then this script could be useful in locating it....

#Script to find a VM from a pool of individual hosts having differ passwords

Add-PSSnapin VMware.VimAutomation.Core

$connectvmhost = "Connect-VIServer host-A -user root -password xyz"
$connectvmhost += "Connect-VIServer Host-B -user root -password 123xyz"

$connectvmhost

Get-VM vm-name -server Host-A, Host-B | select Name, VMhost

Disconnect-VIServer -Confirm:$false

If all hosts are having the same password, then,

$usr = 'user_name'
$pwd = 'password'

$connectvmhost = "Connect-VIServer host-A -user $usr -password $pwd"
$connectvmhost += "Connect-VIServer Host-B -user $usr -password $pwd"

$connectvmhost

Get-VM vm-name -server Host-A, Host-B | select Name, VMhost

Disconnect-VIServer -Confirm:$false

I believe, there would be a better way to do this but this also serves the purpose.

That's it... :)
Tags

Post a Comment

0Comments
Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !
To Top