Difference between revisions of "Script Extracts and Examples (PowerCLI)"

Jump to navigation Jump to search
→‎Ping All VM's On ESX: Updated script (extra error checking/catching)
(→‎Script Extracts: Added "ESX Discovered Networks Hint")
(→‎Ping All VM's On ESX: Updated script (extra error checking/catching))
Line 580: Line 580:
Useful sanity check prior to and after network level changes
Useful sanity check prior to and after network level changes
<source lang="Powershell">
<source lang="Powershell">
$ESX = get-vmhost "ESXToTest"
$esxToFind = "MyESX*"
 
$ESX = get-vmhost $esxToFind
if (!$ESX) {
    Write-Host "ERROR: No ESX found with name matching expression $esxToFind" -Background Red -ForegroundColor DarkRed
    Exit
}


# Get list of VM's on $ESX
# Get list of VM's on $ESX
Line 592: Line 598:
     $ip = (Get-VMGuest -VM $vm).IPAddress[0]
     $ip = (Get-VMGuest -VM $vm).IPAddress[0]
     if (!$ip) {
     if (!$ip) {
         Write-Host "NULL - Skip" -Background DarkYellow -ForegroundColor Yellow
         Write-Host "NULL - Skipping test" -Background DarkYellow -ForegroundColor Yellow
         Continue
         Continue
     }
     }
     Write-Host $ip.PadRight(17) -nonewline
     Write-Host $ip.PadRight(17) -nonewline
    if ($ip -eq '0.0.0.0') {
        Write-Host "Skipping" -Background DarkYellow -ForegroundColor Yellow
        Continue
    }
          
          
     [string]$res = $objPing.Send($ip).Status
     [string]$res = $objPing.Send($ip).Status

Navigation menu