Solved

powershell script help - filter get-distributiongroup

Posted on 2014-03-26
4
1,145 Views
Last Modified: 2014-03-27
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
Comment
Question by:Ben Hart
  • 3
4 Comments
 
LVL 14

Expert Comment

by:Justin Yeung
ID: 39957417
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
 
LVL 14

Author Comment

by:Ben Hart
ID: 39957455
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
 
LVL 14

Expert Comment

by:Justin Yeung
ID: 39957831
Missing -properties *

Get-adgroup -filter * -properties * | ?
0
 
LVL 14

Accepted Solution

by:
Justin Yeung earned 500 total points
ID: 39957832
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article will show, step by step, how to integrate R code into a R Sweave document
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now