Solved

check if ad account is disabled

Posted on 2016-08-16
4
58 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 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 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
DHCP scope restore question Server 2003 to 2012R2 6 59
Delete Msol groups from csv file 2 40
powershell script SMTP report 6 41
Orphaned SIDs on shared folders 3 22
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

822 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