如何远程安装,configuration和维护SNMP?

我正在远程安装Windows Server 2008 R2上的SNMP和SNMP WMI Provider服务,为代理,陷阱和安全选项卡configuration特定选项,然后确保这些服务和设置未被删除或closures。 Zenoss远程监控服务器健康的愿望促成了这一目标的实现。

通过我的在线search,我觉得这可以用Powershell来完成,然后通过组策略推出,但是我对此很陌生,这有点混乱; 我也可能是错的。

我的一些服务器是企业,而一些是标准的都是R2。 我假设我将不得不为所有服务器安装SP1,.Net 4.0和Powershell 3.0,以在任何脚本中获得奇偶性和可靠性。

到目前为止,我已经可以为Powershell编写脚本来调用DISM来安装SNMP服务,并将该脚本设置为GPO中的login脚本,但是我知道这不是最好的方法,因为我不能只是去重新启动整个企业的服务器。

我需要指定以下项目:代理 – 联系人和位置陷阱 – 社区名称和陷阱目标安全性 – 发送身份validation陷阱=是,接受的团体名称只读并接受来自任何主机的SNMP陷阱=是

任何帮助将不胜感激!

SNMP的老旧和脆弱。 微软已经把他们的SNMP引擎置于不赞成使用的状态,所以甚至不希望新版本的Windows包含它。

这听起来像是Powershell新的期望状态configuration的完美工作,但是DSC是复杂的。 这是一个相对沉重的学习承诺,build立一个拉服务器,在整个企业更新Powersehell等。

如果我要在每台机器上运行一个脚本来检查是否安装了SNMP,如果没有安装它,我可能会这样做:

If($(Get-WindowsFeature SNMP-Service).Installed -EQ $False) { Install-WindowsFeature SNMP-Service } 

不pipe你喜欢,你可以分发这个脚本,也许可以作为一个启动脚本。 或者也许可以从一台中央计算机运行一个循环的所有计算机并远程执行安装。

configuration位不是很迷人。 正如我所说,SNMP已被弃用,所以微软不会花费任何精力为SNMP服务创build一堆Cmdlet。

但configuration只是registry设置。 您可以从已configuration的计算机中导出HKLM\SYSTEM\CurrentControlSet\services\SNMP\Parameters * .reg文件,并通过GPO或启动脚本将该.reg文件分发到其他计算机。

或者你可以采取更直接的方式,像这个人: http : //poshcode.org/2066

从poshcode链接:

 $pmanagers = "ADD YOUR MANAGER(s)" $commstring = "ADD YOUR COMM STRING" Import-Module ServerManager #Check If SNMP Services Are Already Installed $check = Get-WindowsFeature | Where-Object {$_.Name -eq "SNMP-Services"} If ($check.Installed -ne "True") { #Install/Enable SNMP Services Add-WindowsFeature SNMP-Services | Out-Null } ##Verify Windows Servcies Are Enabled If ($check.Installed -eq "True"){ #Set SNMP Permitted Manager(s) ** WARNING : This will over write current settings ** reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\SNMP\Parameters\PermittedManagers" /v 1 /t REG_SZ /d localhost /f | Out-Null #Used as counter for incremting permitted managers $i = 2 Foreach ($manager in $pmanagers){ reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\SNMP\Parameters\PermittedManagers" /v $i /t REG_SZ /d $manager /f | Out-Null $i++ } #Set SNMP Community String(s)- *Read Only* Foreach ( $string in $commstring){ reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\SNMP\Parameters\ValidCommunities" /v $string /t REG_DWORD /d 4 /f | Out-Null } } Else {Write-Host "Error: SNMP Services Not Installed"} 

这就是这个想法。 你可能想花更多的时间来打磨和完成,但有一个概念。

编辑:哦,这是一个非常好的MS文档,通过Powershell远程pipe理多个服务器,它有一些好主意: http : //technet.microsoft.com/en-us/library/hh831809.aspx

 function Invoke-WindowsFeatureBatchDeployment { param ( [parameter(mandatory)] [string[]] $ComputerNames, [parameter(mandatory)] [string] $ConfigurationFilePath ) # Deploy the features on multiple computers simultaneously. $jobs = @() foreach($ComputerName in $ComputerNames) { $jobs += Start-Job -Command { Install-WindowsFeature -ConfigurationFilePath $using:ConfigurationFilePath -ComputerName $using:ComputerName -Restart } } Receive-Job -Job $jobs -Wait | Select-Object Success, RestartNeeded, ExitCode, FeatureResult }