VMWare Host QA PowerCLI Script

We were upgrading a bunch of ESXi hosts and needed to QA the guest VM’s after.  I wrote this PowerShell script to list the guest VM’s on a particular host, get all network adaptors/ IP addresses, and ping each and echo out the results.

Add-PSSnapin VMware.VimAutomation.Core -ErrorAction silentlyContinue
$file = "\\FQDN\scripts$\VMWare\Logs\vHostQA-" + $(Get-Date -Format 'M_d_yyyy') + ".txt"
Connect-VIServer $vsphere

$VMhost = Read-Host "Enter the host name as displayed in vCenter"
$VMs = get-vm | Where {$_.VMhost -Like $VMhost}
ForEach ($vm in $VMs){
 $vmObj = get-vm -name $vm
 write-host "Checking: $vmObj"
 $PowerState = $vmObj.PowerState
 If ($PowerState -eq "PoweredON"){
 $NetworkAdapter = $vm.Guest.Nics
 ForEach ($adaptor in $NetworkAdapter){
 $NetworkName = $adaptor.NetworkName
 $connState = $adaptor.Connected
 ForEach ($IPAddress in $adaptor.IPAddress){
 If ($IPAddress.Contains(":")){
 $IP = $IPAddress
 $ping = New-Object System.Net.NetworkInformation.Ping
 $status = [string]($ping.Send($IP)).Status
 $address = [string]($ping.Send($IP)).Address
 catch [System.Net.NetworkInformation.PingException]{$status = $null}
 Success {Write-Host "$vm is up with IP: $address" -foregroundcolor Green
 $NewString = "$vm is up with IP: $address"
 $NewString | Out-File $file -Append -NoClobber -Encoding ASCII}
 Default {Write-Host "$vm not responding. IP: $IP Power State: $PowerState Network: $NetworkName Network Connected: $connState" -foregroundcolor RED
 $NewString = "$vm not responding. IP: $IP Power State: $PowerState Network: $NetworkName Network Connected: $connState"
 $NewString | Out-File $file -Append -NoClobber -Encoding ASCII}
 write-host "$vm not responding. Power State: $PowerState" -foregroundcolor Red
 $NewString = "$vm not responding. Power State: $PowerState"
 $NewString | Out-File $file -Append -NoClobber -Encoding ASCII

Disconnect-VIServer -Server $vsphere -Confirm:$false

View mRemote Passwords

Want to view your mRemote passwords? it’s stored in the variable %password%, just need to echo it out to the screen

Created a new external tool by selecting ‘Tools’ -> ‘External Tools’, Right click and select ‘New External Tool’

On the bottom of the page enter these values

Test by right clicking on you connection -> ‘External Tools’ -> ‘View Password’