VMware Cloud Community
govind80
Contributor
Contributor

ESXi5.1 stops sync with the Dell Open manage essential...looking for script to restart WSMAN service

My ESXi5.1 hosts configured to the Dell Open Manage Essential stops discovering to update the Health status .

So every time i need to restart the WSMAN services login SSH to the ESXi host and restart the WSMAN service (/etc/init.d/wsman restart)

Can someone please to create a script to restart the WSMAN service through PowerCLI.

2 Replies
LucD
Leadership
Leadership

We had this question before, see Restart wsman service via PowerCLI?

Unfortunately there hasn't been any change since then.

See also Restart OMSA 7.2 on esxi 5.1 in the Dell

So I'm afraid running the required commands through a plink.exe session is the only option for now.


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

kunaludapi
Expert
Expert

If you are going to use Plink.exe to ssh in esxi server below script is handy. You will need to download plink.exe tool and keep under c:\windows.

you will need to create a file "C:\scripts\Command.txt" and save it with command  -/etc/init.d/wsman restart

$cred = Get-Credential -Message "Vcenter or esxi username and password"  
Connect-Viserver vcenterserver -Credential $cred 
Add-PSSnapin vmware.vimautomation.core 
$command = "C:\scripts\Command.txt" 
$esxiHosts = Get-VMHost 
$root = "root" 
$Passwd = "Newpassword" 
foreach ($esxiHost in $esxiHosts) { 
  $SSHservice = $esxiHost | Get-VMHostService | where {$psitem.key -eq "tsm-ssh"} 
  if ($SSHservice.Running -eq $False) { 
  $esxiHost | Get-VMHostService | where {$psitem.key -eq "tsm-ssh"} | Start-VMHostService 
  } 
  Write-Output "yes" | plink.exe -ssh root@$esxihost -P 22 -pw $passwd -m $command 
  $esxiHost | Get-VMHostService | where {$psitem.key -eq "tsm-ssh"} | Stop-VMHostService -Confirm:$false 
}

For more you can check it on vGeek: Change ssh banner / motd message file on all esxi servers using powercli

--------------------------------------------------------------- Kunal Udapi Sr. System Architect (Virtualization, Networking And Storage) http://vcloud-lab.com http://kunaludapi.blogspot.com VMWare vExpert 2014, 2015, 2016 If you found this or other information useful, please consider awarding points for "Correct" or "Helpful".