Reputation: 301
I have a csv with employee expiration dates formatted like 8/12/2016, but the Set-ADAccountExpiration
cmdlet is setting the date 8/11/2016. I'm assuming this means 8/11/2016 11:59 PM? This appears to be a bug?
If the user's last day is on 8/12/2016, the last thing we want is for them to get to work that day and be expired. How do I fix this?
I'm using a [string]
variable from the csv called $Row.'Expiration Date'
but having difficulty doing the .AddDays(1)
thing, since it's not [DateTime]
method.
Upvotes: 1
Views: 3112
Reputation: 47812
You need to convert your row into a [DateTime]
:
([DateTime]($Row.'Expiration Date')).AddDays(1)
Also, don't assume that the cmdlet is setting it to 11:59 PM; check for yourself:
Get-ADUser username -Properties AccountExpirationDate
This page has a good writeup about this.
Upvotes: 2