?
Solved

Active Directory Management

Posted on 2013-10-23
4
Medium Priority
?
155 Views
Last Modified: 2014-03-29
Hi there,

I am trying to configure automatic user account expiration in Windows 2008 R2 Active Directory.  I would like i tot use the DSQuery and DSMod commands.  I have piped a DSMod in a DSQuery but syntax is wrong.  I need it to automatic disable user accounts after 90 days of inactivity.  Can someone help?

Thanks in advance.
0
Comment
Question by:jasonhdz
[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
4 Comments
 
LVL 53

Assisted Solution

by:Will Szymkowski
Will Szymkowski earned 501 total points
ID: 39595246
This is very easy to accomplish using Powershell. I have added code below to accomplish what you are looking for...

Import-module activedirectory
$expires = get-date
$UserName = read-host "Enter Username Here"
Set-ADUser $Username -AccountExpirationDate $expires.adddays(90)

This script will do accounts 1 by 1 if you want me to modify it based on a CSV or txt file, please advise.


Will.
0
 
LVL 3

Assisted Solution

by:w_richard
w_richard earned 498 total points
ID: 39597535
0
 
LVL 1

Author Comment

by:jasonhdz
ID: 39607688
Thanks everyone.

I basically need the script to be able to check:
1.  The last time users in active directory logged in
2.  If this is more than 60 days, then disable the account.

I dont have a X number of static users, it may increase or decrease significantly. that is why i need it to be able to check all users...maybe on a daily basis.

Thanks.
0
 

Accepted Solution

by:
dave121 earned 501 total points
ID: 39887511
Hi,

You can refer to the link mentioned below for the powershell code-
http://ss64.com/ps/set-adaccountexpiration.html
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
Compliance and data security require steps be taken to prevent unauthorized users from copying data.  Here's one method to prevent data theft via USB drives (and writable optical media).
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
Suggested Courses
Course of the Month11 days, 10 hours left to enroll

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