Jay Thomas
asked on
Add feature using powershell to server 2008r2
Hi all,
I need to add the SNMP feature to over 200 windows server 2008 R2 servers. I have the command to add the feature using powershell when I logged on locally but I'd like the command to add it to a remote server on the same domain, I am using a domain admin account.
I have googled a solution but I'm not a powershell guy so having difficulty understanding it.
For local I know it is:
Import-Module servermanager
Get-WindowsFeature
Add-WindowsFeature SNMP-Services
Any help appreciated.
I need to add the SNMP feature to over 200 windows server 2008 R2 servers. I have the command to add the feature using powershell when I logged on locally but I'd like the command to add it to a remote server on the same domain, I am using a domain admin account.
I have googled a solution but I'm not a powershell guy so having difficulty understanding it.
For local I know it is:
Import-Module servermanager
Get-WindowsFeature
Add-WindowsFeature SNMP-Services
Any help appreciated.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi David, many thanks. How do I target the script at a remote server?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you only need to do this once, I would suggest using the SNMP Enabler from Solarwinds.
http://www.solarwinds.com/products/freetools/snmp-enabler-for-windows/enable-snmp.aspx
It is a free tool and worked wonders when I enabled SNMP on our systems.
http://www.solarwinds.com/products/freetools/snmp-enabler-for-windows/enable-snmp.aspx
It is a free tool and worked wonders when I enabled SNMP on our systems.
ASKER
Thank you for the info David - much appreciated.
Can I just check that I have this correct. The script will add the SNMP feature on the target machine and not cause an issue if the feature was already enabled. Will it then go on to populate the SNMP community within the SNMP service too?
Can I just check that I have this correct. The script will add the SNMP feature on the target machine and not cause an issue if the feature was already enabled. Will it then go on to populate the SNMP community within the SNMP service too?
Hi Jason,
Just a note the name of the service is SNMP-Service and not SNMP-Services so you will have to remove the last s character from the name of the service, if you don´t do this you will be presented with an error.
"The script will add the SNMP feature on the target machine ".
Yes, this piece of code will check if the service is installed or not, if not the service will be installed.
"if the feature was already enabled"
This is checked by this piece of code, if the service is not enabled and not configured this will be configured.
But if the service is already enabled and configured, the settings will be override on the Reg Keys. So be carefully.
I hope this will be what you want.
Regards
Just a note the name of the service is SNMP-Service and not SNMP-Services so you will have to remove the last s character from the name of the service, if you don´t do this you will be presented with an error.
"The script will add the SNMP feature on the target machine ".
Yes, this piece of code will check if the service is installed or not, if not the service will be installed.
#Check If SNMP Services Are Already Installed
$check = Get-WindowsFeature | Where-Object {$_.Name -eq "SNMP-Service"}
If ($check.Installed -ne "True") {
#Install/Enable SNMP Services
Add-WindowsFeature SNMP-Service | Out-Null
}
"if the feature was already enabled"
This is checked by this piece of code, if the service is not enabled and not configured this will be configured.
But if the service is already enabled and configured, the settings will be override on the Reg Keys. So be carefully.
##Verify Windows Services 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"}
I hope this will be what you want.
Regards
ASKER
Many thanks
http://social.technet.microsoft.com/wiki/contents/articles/4032.how-to-install-snmp-remotely.aspx
This does not use powershell but it uses batch file and PSExec.
Thanks,
-Prashant Girennavar.