[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

check if ad account is disabled

Posted on 2016-08-16
4
Medium Priority
?
149 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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.
A walk-through example of how to obtain and apply new DID phone numbers to your cloud PBX enabled users that are configured in Office 365. Whether you have 1, 10 or 100+ users in your tenant, it's quite easy to get them phone-enabled and making/rece…
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…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

649 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