Mass enabling windows features via PowerShell

Recently I needed to add the SNMP service to a few hundred systems. There are few more involved methods for this via unattended installs with SCCM or batch scripted GPO-linked entries but if you want a quick and easy way how, try the below.

Target OS: Server 2008, 2008R2, 2012 and 2012R2

Source system was a 2012R2 box with the AD and ServerManager PowerShell modules installed

Import-Module ActiveDirectory
$myservers = Get-ADComputer -SearchBase "OU=My Servers,DC=liquidobject,DC=com" -Filter "*"
foreach($i in $myservers)
 $mysession = New-PSSession -ComputerName $
 Invoke-Command -Session $mysession {Import-Module Servermanager}
 Invoke-Command -Session $mysession {Add-WindowsFeature SNMP-Service}

Any server in the OU offline or running an unsupported os (ie Server 2003….we all have them) will throw an error. The above is pretty basic example on how you can install any Windows feature remotely. The remote PSSession and Invoke-Command methods allow you to perform any supported PowerShell command remotely.

In the event your running a legacy version of Windows, there are still options available. The limitation of the below is that it requires you to login to the given system and run the command with an administrative command prompt.

servermanagercmd.exe -install snmp-service
, , , , ,
October 16, 2014 at 1:59 pm Comments (0)

Using PowerShell to copy Active Directory Group Membership

If you’ve ever needed to group membership between to AD groups you could do this one by one which while does work, what happens if you have a list with 10, 20, 30,….or even 5000+ users? To copy the membership from one group into another via PowerShell under Server 2008 is a simple two lines (plus import command).


Import-Module ActiveDirectory

$mymembers = Get-ADGroupMember -identity My_Source_Group_Name | Select-Object SamAccountName

foreach($i in $mymembers){Add-ADGroupMember -Identity My_Destination_Group_Name -Members $i.SamAccountName}
, ,
November 18, 2011 at 11:35 am Comments (2)