Solved

Active Directory Management

Posted on 2013-10-23
4
143 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
4 Comments
 
LVL 53

Assisted Solution

by:Will Szymkowski
Will Szymkowski earned 167 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 166 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 167 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

Join & Write a Comment

Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
This tutorial will give a short introduction and overview of Backup Exec 2012 and how to navigate and perform basic functions. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as conne…
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…

762 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

21 Experts available now in Live!

Get 1:1 Help Now