Solved

Powershell help

Posted on 2014-11-03
7
115 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
[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
  • 4
  • 2
7 Comments
 
LVL 71

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
Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

 
LVL 40

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 40

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

Problems using Powershell and Active Directory?

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

Question has a verified solution.

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

This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

736 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