Solved

Active Directory Management

Posted on 2013-10-23
4
151 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 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

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

This article shows the method of using the Resultant Set of Policy Tool to locate Group Policy that applies a particular setting.
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…
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…

733 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