Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Setting users in a CSV AD accounts to expire in 90 days

$
0
0

I have over 100 users that I need to extend their AD accounts to expire in 90 days.

I'm a new comer to Powershell and I'm stumped with writing a script to parse a CSV file.

My CSV is simple, heading 'sAMAccountName' and a list of the user IDs.

Here is my script:

"Import-Module ActiveDirectory
$List = Import-CSV H:\Scripts\90-dayExpire.csv
ForEach ($User in $List)
{
# Set the expiration date for 90 days into the future
Get-ADUser -Identify $User.sAMAccountName |Set-ADAccountExpiration -timespan 90
}"

I've tried several variations of the above, however, all returned errors.  The script above doesn't return an error, but it doesn't extend the account an additional 90 days.

I was able to extend an individual account, but not from the CSV.

Any help will be appreciated.

Thank you!!

 

 

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles