• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1456
  • Last Modified:

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.
0
Ben Hart
Asked:
Ben Hart
  • 3
1 Solution
 
Justin YeungCommented:
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

0
 
Ben HartAuthor Commented:
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?
0
 
Justin YeungCommented:
Missing -properties *

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

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now