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
Solved

powershell script help - filter get-distributiongroup

Posted on 2014-03-26
4
1,215 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Start-VM 3 18
Convert .csv to tab delimited text 11 33
Have Pshell That Creates Directories By Date, But... 1 25
AWK: Pytthagoras bp script Part deux 22 32
Synchronize a new Active Directory domain with an existing Office 365 tenant
Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…

856 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