- This topic has 5 replies, 3 voices, and was last updated 2 months, 1 week ago by
March 16, 2020 at 3:53 pm #210588
I’m just getting into learning more about powershell and the second project I have seems simple enough, but I can’t find the command to ‘clear’ the flag in ADSI.
The end goal is to have a prompt where someone can type in a username and it hit up ADSI to clear one flag from the account properties. If someone has a template I can use, I can expand off of it from there and fill in other flags and domain options I would really appreciate it.
If this is more difficult than I’m anticipating though, just let me know! I may have bitten off more than I can chew.
March 16, 2020 at 4:29 pm #210594ParticipantTopics: 4Replies: 2231Points: 5,414Rank: Community MVP
I think your description is a little vague. What “flag” would you like to “clear”? What ahve you tried already? You should search the internet and this forum for examples – there are thousands. If already have code you’ve got stuck with please share that code and we can try to help you.
Please read the instructions for this forum contained in the very first post of this forum: Read Me Before Posting! You’ll be Glad You Did!
March 16, 2020 at 4:59 pm #210603
Thanks for the reply!
Unfortunately the field name is proprietary so most of my search results are skewed, but it would be similar to the “homePhone” field in ADSI. There is a ‘clear’ button to remove any value set. Typically the field is a true, false, or <not set>. I just can’t find the command to say Clear to put it as the <not set> value.
For example I’ve got this. It’s not super complex, but I’m just missing one piece. Sorry if this is a dumb question:
#This part shows the current account info Get-ADUser -identity USERNAME -properties Name,FLAG | Select-Object -property Name,FLAG #This part should be what sets it to <not set> Set-ADUser USERNAME -identity USERNAME -FLAG ??? #This confirms the change Get-ADUser -identity USERNAME -properties Name,FLAG | Select-Object -property Name,FLAG
March 16, 2020 at 5:08 pm #210615
March 16, 2020 at 8:08 pm #210654ParticipantTopics: 1Replies: 2Points: 19Rank: Member
If the attributes you are needing are custom, this has worked for me in the past.
$User = Get-ADUser -Identity jdoe -Properties yourFlagAttributeName
Set-ADUser –Identity $User -Clear "yourFlagAttributeName"
March 16, 2020 at 8:23 pm #210663
It worked like a charm guys.
I had misunderstood the book I was reading over and took the -clear as a statement rather than a command so the errors didn’t make sense. After I saw it written out from you guys it made perfect sense.
Thanks for your help!
- You must be logged in to reply to this topic.