Convert all group types in OU with Powershell

Using the following command will convert every group in that OU (and sub OUs unless you add the -SearchScope OneLevel switch) to type Distribution with Scope Global.

get-adgroup -filter * -SearchBase "OU=Groups,DC=work,DC=com" | ForEach {$x=[ADSI]"LDAP://CN=$($_.Name),OU=Groups,DC=work,DC=com"; $x.Put("groupType","2"); $x.setInfo()}

To change to the following group types/scopes use the following values for “groupType”,

Distribution – Universal = 8
Distribution – Domain Local = 4
Distribution – Global = 2

**STILL CANNOT GET THE FOLLOWING TO WORK**
Security – Universal = -2147483640
Security- Domain Local = -2147483644
Security- Global = -2147483646

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s