PowerShell中的Set-ADAccountExpiration将AD帐户设置为-1天。为什么? [英] Set-ADAccountExpiration in PowerShell sets AD account -1 day. Why?

查看:1129
本文介绍了PowerShell中的Set-ADAccountExpiration将AD帐户设置为-1天。为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆