We help IT Professionals succeed at work.

Add feature using powershell to server 2008r2

1,906 Views
Last Modified: 2014-09-08
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.
Comment
Watch Question

CERTIFIED EXPERT

Commented:
Try below.

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.
David Paris VicenteInfrastructure Designer
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Hi David, many thanks. How do I target the script at a remote server?
Infrastructure Designer
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
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.

Author

Commented:
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?
David Paris VicenteInfrastructure Designer

Commented:
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.
#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
}

Open in new window


 "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"}

Open in new window


I hope this will be what you want.

Regards

Author

Commented:
Many thanks

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.