VMware Cloud Community
prateekpatalVCP
Enthusiast
Enthusiast

PoqweCLI script for host connection state

Hello All,

 

I am looking for a powercli script that can fetch ESXi host connection state such as Host disconnected or non responding,

Thanks in advance

Moderator edit by wila: Moved to PowerCLI discussions

Prateek
Labels (1)
0 Kudos
5 Replies
LucD
Leadership
Leadership

Like this?

Get-VMHost | Select Name,State


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
prateekpatalVCP
Enthusiast
Enthusiast

No Lucd, it will give output to all connected and disconnected hosts. I need only disconnected hosts and non-responding lists and the output will be sent to mail.

 

thanks.

Prateek
0 Kudos
LucD
Leadership
Leadership

That is not what you asked for with "I am looking for a powercli script that can fetch ESXi host connection state such as Host disconnected or non responding,".
Plus now you all of a sudden have an email requirement.

Sorry, I'm not falling for these never-ending threads anymore.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

prateekpatalVCP
Enthusiast
Enthusiast

I managed to get disconnected host in powercli output. i want this output to be send to the mail. trying below but its not working as expected.

 

Get-VMHost |Where{$_.ConnectionState -eq 'Disconnected'} |Select Name,ConnectionState

Send-MailMessage -from 'mail@.test..com' -to "mail@.test.com.com' -Subject 'Report' -smtpserver 'smtp server'

Prateek
0 Kudos
LucD
Leadership
Leadership

You need to use the Body parameter on the Send-MailMessage cmdlet.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos