HI LUC.D,
could you please check the following script. this is to get all hosts in vcenters which are not responding and then start vpxa service by direcly login to esxi boxes.
1:blue part will get info of esxi hosts which are not responding in all vcenters and disconnect from vcenters.
2:orange will connect to esxi host and restart vpxa agent .
3:can i pass info stored in $esxi_notres(hosts which are not responding) to function connect-esxi?
4:alsowhat is the key for hostd service in get-vmhostservice output.
$vc=@("tcclabc002vctt01.servers.chrysler.com","shccertvcs01.shdc.chrysler.com")
Connect-VIServer -Server $vc -user "administrator@vsphere.local" -password ""
$esxi_notres=get-vmhost|Where-Object{$_.connectionstate -eq "notresponding"}
$esxi_main=get-vmhost|Where-Object{$_.connectionstate -eq "maintenance"}
$esxi_notres.name
disconnect-viserver -server "*" -force -confirm:$false
$global:defaultviserver
function connect-esxi
{
[cmdletbinding()]
param(
[parameter(mandatory=$true)]
[string[]]$esxihost
)
connect-viserver -server $esxihost -username "root" -password ""
get-vmhost $esxihost|Get-VMHostService|where-object{$_.key -eq "vpxa"}|start-VMHostService
}
Thanks for your suport.