File this one under windows automation.
We are transitioning to a new Zabbix monitoring installation.
We discovered after a network outage several windows snmp services needed to be restarted to restore monitoring.
Here is the powershell pipeline I used to do this:
(there is no restart method so we call stop, then start)
Assumes TCP port 135 is open to the servers listed in snmprestartlist.txt
[vSphere PowerCLI] C:\> get-content c:\snmprestartlist.txt | foreach-object {Get-Service -ComputerName $_ | Where-Object { $_.Name -eq "SNMP" } | ForEach-Object {$_.Stop() }}
[vSphere PowerCLI] C:\> get-content c:\snmprestartlist.txt | foreach-object {Get-Service -ComputerName $_ | Where-Object { $_.Name -eq "SNMP" } | ForEach-Object {$_.Start() }}
Check the status is now running:
[vSphere PowerCLI] C:\> get-content c:\snmprestartlist.txt | foreach-object {Get-Service -ComputerName $_ | Where-Object { $_.Name -eq "SNMP" } | Format-List *}