VMware Cloud Community
tmcgrath
Contributor
Contributor

How to restart vshield-endpoint-mux via powercli?

I have an open ticket with VMWare. They are stumped! We have vm's that are disconnecting because the host is causing all the guest o flap the VSEPLFT from connected to disconnected... If I could somehow script :

/etc/init.d/vShield-Endpoint-Mux start/stop/restart

Via PowerCLI to run on all hosts in a cluster that would be great! I am having some difficulty today searching, and running out of ideas I have tested a few different ideas with no success.

Tags (1)
0 Kudos
2 Replies
LucD
Leadership
Leadership

Is SSH enabled on those ESXi nodes?

Or can it be enabled on those nodes?


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

0 Kudos
bdmpastx
Contributor
Contributor

I have POSH-SSH installed and I was able to build and run this. Replace your ESXi username and password in the single quotes. You must be connected to a vcenter server as well. "Connect-viserver"

$username = ''

$Password = ConvertTo-SecureString '' -AsPlainText -Force

$credential = New-Object System.Management.Automation.PSCredential($username,$Password)

$Clusters = Get-Cluster

foreach($cluster in $clusters){

    $esxhosts = Get-VMHost

    foreach($esxhost in $esxhosts){

        $session = $null

#Starts SSH services on the ESXi

        $esxhost|Get-VMHostService | where-object {$_.key -eq "TSM-SSH"} | start-vmhostservice -confirm:$false

        $esxhost|Get-VMHostService | where-object {$_.key -eq "TSM-SSH"} | Set-VMHostService -Policy Off

#Start the SSH session with POSH SSH

        $session = New-SSHSession -Credential $credential -ComputerName $esxhost -AcceptKey:$true

        If($session -ne $null){

#Run the command on SSH

        Invoke-SSHCommand -index $session.SessionId -command "/etc/init.d/vShield-Endpoint-Mux restart"

#Remove the session

        $session|Remove-SSHSession

        }else{write-host "$esxhost has a bad password"}

#Stop SSH Services on the host

        $esxhost|Get-VMHostService | where-object {$_.key -eq "TSM-SSH"} | stop-vmhostservice -confirm:$false

        $esxhost|Get-VMHostService | where-object {$_.key -eq "TSM-SSH"} | Set-VMHostService -Policy On

#Restart the guest introspection VM. This is needed so that the muxconfig.xml is rebuilt on the ESXi

        $GIVM = $esxhost|get-vm -name "Guest Introspection*"

        Restart-VM -VM $GIVM -Confirm:$false}

        }

0 Kudos