PoweredOn VM but NICs are Disconnected

Here is a script on VMware via Powershell. As long as you have installed the PowerCLI module, you can run this via the standard Powershell. I have taken the script and created a PS1 file to run through the list and email it to you. This will help in the cases whereby an application or service is not cluster aware and a migration takes place. Or if a Hosts reboots and the VM comes up but for some reason, it is not able to auto-connect. Now all your resources may not have access to VCenter or may not know how to check. This email will help to notify the team.

Connect-VIServer <VCenter FQDN>

$smtpsettings = @{

To =  “user@domain.co.za”

From = “support@domain.co.za”

Subject = “VMware PoweredOn Systems with Disconnected NICs”

SmtpServer = “<smtp server”


$objs = @()

$emailBody = “<table border=’1’><tr><th>Parent</th><th>NetworkName</th><th>ConnectionState</th><th>”

$csvs = Get-VM | Where-Object {$_.Powerstate -eq “PoweredOn”} | Get-NetworkAdapter | Where-Object {$_.

ConnectionState -match “NotConnected”} | select Parent,NetworkName,ConnectionState

foreach ( $csv in $csvs )


      $emailBody = $emailBody + “<tr><td>” + $csv.Parent + “</td><td>” + $csv.NetworkName + “</td><td>”  + $csv.ConnectionState + “</td></tr>”


$emailBody = $emailBody + “</table>”

Send-MailMessage @smtpsettings -Body $emailBody -BodyAsHtml -Encoding ([System.Text.Encoding]::UTF8)

Add the above on to a text document. Then save it as a .ps1 file. When you run it, it will run in Powershell and email you. You can run this manually or create a task scheduler to run.

Be the first to comment

Leave a Reply

Your email address will not be published.


This site uses Akismet to reduce spam. Learn how your comment data is processed.