PowerShell Clear-ADAccountExpiration 的执行方式与手动方法不同

标签 powershell active-directory powershell-2.0

我在使用 PowerShell Clear-ADAccountExpiration 将 Active Directory 中的帐户到期日期重置为从不时遇到问题。

这是一个即将过期的帐户:

get-ADUser osbor_ri -properties * | select AccountExpirationDate,accountExpires | fl

AccountExpirationDate : 31/12/2013 17:00:00
accountExpires        : 130330692000000000

如您所见,它将在 2013 年 12 月 31 日 17:00:00 到期。 我想清除这个过期并将其设置为Never过期;所以我使用以下cmdlet:

Clear-ADAccountExpiration osbor_ri 

这会清除 AD 中的 AccountExpirationDate 变量,但不会将 accountExpires 清除为 0,而是每次都设置为 9223372036854775807

get-ADUser osbor_ri -properties * | select AccountExpirationDate,accountExpires | fl

AccountExpirationDate : 
accountExpires        : 9223372036854775807

但是,当我在 AD 中使用手动方法将帐户设置为永不过期时,accountExpires 变量设置为 0

enter image description here

get-ADUser osbor_ri -properties * | select AccountExpirationDate,accountExpires | fl

AccountExpirationDate : 
accountExpires        : 0

为什么 Powershell Clear-ADAccountExpiration 没有像设置帐户时手动方法那样将 accountExpires 变量清除为 0帐户永不过期?

离开 accountExpires = 9223372036854775807 是否意味着该帐户仍会在某个时刻过期?

最佳答案

The date when the account expires. This value represents the number of 100-nanosecond intervals since January 1, 1601 (UTC). A value of 0 or 0x7FFFFFFFFFFFFFFF (9223372036854775807) indicates that the account never expires.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms675098(v=vs.85).aspx

关于PowerShell Clear-ADAccountExpiration 的执行方式与手动方法不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18595588/

相关文章:

PowerShell 脚本将 SQL 导出为 CSV 添加分隔符

powershell - 使用 powershell 对象执行脚本

Asp.net 从 IIS 搜索 Active Directory

git - Get-ChildItem 执行 git status

windows - PowerShell:(ConvertTo-* | Set-Content) 和 (Export-*) 之间的区别?

用于打印所有子文件夹的 PowerShell 脚本

arrays - 从数组创建对象

powershell - 具有延迟变量扩展的 For 循环中 "!"文字问题的解决方法

python - 克服 Active Directory 的 1000 条记录限制

powershell - 删除计算机 cmdlet 访问被拒绝