[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

powershell script help - filter get-distributiongroup

Posted on 2014-03-26
4
Medium Priority
?
1,405 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A brief introduction to what I consider to be the best editor for PowerShell.
Windows 10 came with  a lot of built in applications, Some organisations leave them there, some will control them using GPO's. This Article is useful for those who do not want to have any applications in their image (example:me).
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses

649 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