Solved

check if ad account is disabled

Posted on 2016-08-16
4
35 Views
Last Modified: 2016-08-16
How can I check to see if and AD account is disabled?  I assume the code below does not work but this is what im thinking

if(samaccountname.disabled = true){

do this

}
0
Comment
Question by:Roccat
  • 2
  • 2
4 Comments
 
LVL 29

Expert Comment

by:Rich Weissler
ID: 41757791
Once you get the User object (via get-aduser), you can check the 'enabled' property...
(I did a "get-aduser <username> -properties enabled", then could check the 'enabled' property... if false, then the account is disabled.)
0
 

Author Comment

by:Roccat
ID: 41757797
Thank you. What is the syntax to check if the enabled property is true?
0
 
LVL 29

Accepted Solution

by:
Rich Weissler earned 500 total points
ID: 41757807
Sorry...
$a = get-aduser <username> -properties enabled
if (! $a.enabled) {
   do this if disabled
}
else {
    do this if enable
}

Open in new window

0
 

Author Closing Comment

by:Roccat
ID: 41757830
Thank you!!
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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…
Synchronize a new Active Directory domain with an existing Office 365 tenant
This video discusses moving either the default database or any database to a new volume.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

746 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

11 Experts available now in Live!

Get 1:1 Help Now