?
Solved

check if ad account is disabled

Posted on 2016-08-16
4
Medium Priority
?
107 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
[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
  • 2
  • 2
4 Comments
 
LVL 30

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 30

Accepted Solution

by:
Rich Weissler earned 2000 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

Need protection from advanced malware attacks?

Look no further than WatchGuard's Total Security Suite, providing defense in depth against today's most headlining attacks like Petya 2.0 and WannaCry. Keep your organization out of the news with protection from known and unknown threats.

Question has a verified solution.

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

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

752 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