Reputation: 37
Please Note: I am a newbie to Powershell
I would like to Get an ADusers AccountExpirationDate and Add 90days to the AD user's Expiration Date. Tried the
Get-ADUser -Identity $username | Set-ADAccountExpiration -TimeSpan 90.0:0
However, it adds 90 days to the current day under the AD user's account. Is there a way to specify adding 90 days to an ADUser
AccountExpirationDate
?
Upvotes: 1
Views: 828
Reputation: 60370
I think this works. If I understand correctly, you want to add 90 days to the current value of AccountExpirationDate
.
$usr = Get-ADUser -Identity $username -Properties AccountExpirationDate
$newExp = $usr.AccountExpirationDate.AddDays(90)
Set-ADAccountExpiration -Identity $usr -DateTime $newExp
Upvotes: 1