This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
Hi guys
Fairly new to scripting. This should be fairly simple and i'm sure i've just not got my head around something properly. In this scenario, I have created a test user, disabled, with no account expiration date. The end goal is to take an OU of disabled users and re-enable them while adding an account expiration date. Here is my (not working) script so far...(my .csv headers are "samAccountName" and "Expiry" - can anyone assist?
Import-Module ActiveDirectory
Import-Csv "C:\Test290720.csv" | ForEach-Object {
$samAccountName = $_."samAccountName"
$Expiry = $_."DateTime"
Get-ADUser -Server "HCVZ306.edu.XXXXXXX.net" -Identity $samAccountName |
Set-ADAccountExpiration -DateTime $Expiry | Enable-ADAccount
}
Subreddit
Post Details
- Posted
- 4 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/PowerShell/...