Link to home
Start Free TrialLog in
Avatar of Ben Hart
Ben HartFlag for United States of America

asked on

powershell script help - filter get-distributiongroup

I need to bulk modify around 75 distribution groups.. on many we have the flags attribute set with a 1.  I'd like to get-distributiongroup with a filter pulling all the DL's with that flags=1, then Set them all with a modification to the Notes: field adding the words 'no sync'.

My hangup so far is filtering based on that specific attribute and what type of array to load them into.
Avatar of Justin Yeung
Justin Yeung
Flag of United States of America image

this will get all groups with attribute Flags equal 1 and add info (Notes) with no sync

Import-Module ActiveDirectory
$groups = get-Adgroup -Filter * | ? {$_.Flags -eq "1"}
foreach ($group in $groups)
{
Set-ADGroup $group.SamAccountName -Add @{info = "no sync"}
}

Open in new window

Avatar of Ben Hart

ASKER

Running the get-adgroup line alone to judge the results.. I get nothing returned.

get-Adgroup -Filter * | ? {$_.Flags -eq "1"}

Open in new window


Should I specify the OU to run against?
Missing -properties *

Get-adgroup -filter * -properties * | ?
ASKER CERTIFIED SOLUTION
Avatar of Justin Yeung
Justin Yeung
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial