Solved

Powershell help

Posted on 2014-11-03
7
112 Views
Last Modified: 2014-11-04
Looking for a short script to do the following:

Search AD object for the following attributes: info which would be set to 'no sync' and flags set to '1'.  If found null both values and possible report back the accounts found with either of those two attributes set.
0
Comment
Question by:Ben Hart
  • 4
  • 2
7 Comments
 
LVL 70

Expert Comment

by:Chris Dent
ID: 40421124
Just use an LDAP filter when you're requesting it the users.
(&(objectClass=user)(objectCategory=person)(info=no sync)(flags=1))

Open in new window

I assume you've extended the schema since neither info or flags exist in the schema by default. If you have not extended the schema you're going to have to explain which attributes you're looking for.

Chris
0
 
LVL 14

Author Comment

by:Ben Hart
ID: 40421853
Well the functional level is 2008.. is there an extension that I have missed thats separate?
0
 
LVL 14

Author Comment

by:Ben Hart
ID: 40421885
Ok so yeah. I'm missing something here.  Those two attributes exist under Advanced Features but that query returns nothing.
0
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 39

Expert Comment

by:footech
ID: 40422031
Try this.
get-adobject -filter {info -eq "no sync" -and flags -eq "1"}

Open in new window

It's a little odd, according to this link which shows all AD attributes, flags is on the list, but not info.
http://msdn.microsoft.com/en-us/library/ms675090(v=vs.85).aspx
I have "info" in my AD as well when I look at an object and I haven't extended my schema except for the installation of Exchange.
0
 
LVL 14

Author Comment

by:Ben Hart
ID: 40422054
Same here.. Exchange 2010 would have been the last schema change that I know of.

What I am trying to do is remove all attribute data that's currently blocking an unknown amount of objects from syncing via FIM.  Our parent company set all the FIM (PCNS) stuff up and we could use either flags = 1 or info = no sync to block syncing.
0
 
LVL 39

Accepted Solution

by:
footech earned 500 total points
ID: 40422300
You would probably want to limit your search to specific OUs using the -searchbase parameter of Get-ADObject.  Examine the returned results to verify that there aren't some objects which should be excluded.  I know in my environment, I have some Group Policy objects that have flags set to 1.  Couldn't tell you what it means though.
Get-ADObject -filter {info -eq "no sync" -or flags -eq "1"} | Set-ADObject -Clear info,flags -WhatIf

Open in new window

0
 
LVL 14

Author Comment

by:Ben Hart
ID: 40422399
Beautiful.  Worked like a pack mule.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Are you one of those front-line IT Service Desk staff fielding calls, replying to emails, all-the-while working to resolve end-user technological nightmares? I am! That's why I have put together this brief overview of tools and techniques I use in o…
The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

910 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

22 Experts available now in Live!

Get 1:1 Help Now