PowerShell中的Set-ADAccountExpiration将AD帐户设置为-1天。为什么? [英] Set-ADAccountExpiration in PowerShell sets AD account -1 day. Why?
问题描述
我有一个csv,员工到期日期的格式为8/12/2016,但 Set-ADAccountExpiration
cmdlet设置日期8/11/2016。我假设这意味着8/11/2016 11:59 PM?这似乎是一个错误?
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?
如果用户的最后一天是在8/12/2016,我们想要的最后一件事是他们当天工作,并过期。我该如何解决?
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?
我使用来自csv $ Row的
[string]
' ,因为它不是
[DateTime]
方法。
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.
推荐答案
您需要将您的行转换为 [DateTime] / code>:
You need to convert your row into a [DateTime]
:
([DateTime]($Row.'Expiration Date')).AddDays(1)
该cmdlet将其设置为11:59 PM;检查自己:
Also, don't assume that the cmdlet is setting it to 11:59 PM; check for yourself:
Get-ADUser username -Properties AccountExpirationDate
这篇关于PowerShell中的Set-ADAccountExpiration将AD帐户设置为-1天。为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!