To do this, instead of creating an interactive remoting session, we will instead use Invoke-Command to send a prebuilt block of code known as a scriptblock to one or many different computers at once. Now that you know the basics of setting up SNMP, we can take the code we came up with and easily adapt it to multiple servers as well. Viewing SNMP configuration The Install-SNMP function ^
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\services\SNMP\Parameters\ValidCommunities" Name $string.Name -Value $valĪfter running this code, you can then go to the Windows Services console and view the SNMP Service Properties –> Security tab to see that the SNMP service recognizes all of the strings. I've defined a read-only community string as a 4 and a read/write community string as an 8, but I don't want to remember this! $strings = 'ro' We're getting a little fancy here, but that's what PowerShell is for! In the example below, I'm defining all the community strings and their right levels in a plain-English way. We'll do this again via the registry, but this time the appropriate key is called ValidCommunities. Once you've added the permitted managers, it's time to add one or more community strings. New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\services\SNMP\Parameters\PermittedManagers" Name $i -Value $managerĪfter this runs, the PermittedManagers key will now look something like this: By default, 1 is already set for localhost, so I'm starting at 2 and creating each manager entry as a value. You can see below that incrementing numbers starting at 1 define the permitted managers. Select Yes, if you are asked whether you want to allow Outlook to make changes. If you dont see Enable Updates or if it is greyed out, it means that automatic updates are enabled or that your Office administrator has set up a group policy to update Outlook. I can add them both to the PermittedManagers key by using the New-ItemProperty cmdlet. Go to the File tab, and choose Office Account. I'd like to allow servers called and to query this SNMP service. The permitted managers are stored in the PermittedManagers key inside the SNMP Windows service key located at HKEY_LOCAL_MACHINE. First, let's add a few permitted managers. We can add both permitted managers and community strings via the registry. True No Success Configure the permitted manager ^Īfter installing the SNMP service feature, we can now configure both the permitted managers and add any community strings. Success Restart Needed Exit Code Feature Result : PS C:\> Install-WindowsFeature -Name 'SNMP-Service','RSAT-SNMP'
These two features will install the SNMP service itself and make the options available should we choose to configure the SNMP service via the Services GUI later.
I'll use this command to install the SNMP-Service and RSAT-SNMP features. The first command I need to run is Install-WindowsFeature. Once I've established a PSRemoting session, I can begin executing commands on the remote server. PS> Enter-PSSession -ComputerName 'WINSRV2016'