#powershell SNMP Services Administration (Part 5)

Putting into practice what we have discussed so far, this script illustrates how an administrator can use PowerShell remoting to configure/set SNMP settings on a bunch of Windows machines from a distance.

#requires -version 3.0
###############################################################################
# Copyright (c) 201x-2018 leedesmond.com
# All Rights Reserved. Use at your own risk and responsibility.
# Version 1.00
#
# Configure SNMP settings on multiple Windows machines remotely.
#
# REQUIREMENTS: PowerShell Remoting enabled on target hosts
#
###############################################################################
#
function Configure-SNMP($pools)
{
$objs = @()
$pools | % {
$PsItem | % {
$PsItem.Computers | % {
$objs +=
Invoke-Command -ComputerName $PsItem `
-ScriptBlock ${function:Set-SNMP}
}
}
}
$objs
}

#usage sample
$VerbosePreferenceOld = $VerbosePreference
$VerbosePreference = “Continue”

$site = “HK”
$role = “*Registrar*” #”*Mediation*” #”*Chat*”
$pools = Get-CsPool -Site $site
$pools1 = $pools | ? Services -like $role

. .\Set-SNMP.ps1
$objs = Configure-SNMP $pools1

#assume only 1 pool otherwise adjust accordingly
$objs | ogv -Title “$($pools1.Identity) SNMP Settings $($(Get-Date))”

$VerbosePreference = $VerbosePreferenceOld

Bookmark the permalink.

Leave a Reply