Kar*_*son 2 powershell active-directory
作为主题陈述.如何将一天额外的一天添加到所选用户帐户.
我知道AD遵循Windows文件时间.有谁知道最简单和最少编写代码的方法?
您可以accountExpires通过Windows Server 2008 R2中包含的Set-ADUser cmdlet 修改AD用户的属性:
Import-Module activedirectory
$expireDate = (Get-ADUser -Identity "John Appleseed" -Properties accountExpires).accountExpires
$renewedExpireDate = ([System.DateTime]::FromFileTime($expireDate)).AddDays(1)
Set-ADUser -Identity "John Appleseed" -AccountExpirationDate $renewedExpireDate
Run Code Online (Sandbox Code Playgroud)
如您所述,accountExpires属性的值表示为Windows文件时间,它是一个64位整数.在此示例中,我们将其转换为DateTime以轻松修改它,然后将其传递给-AccountExpirationDate参数以更新用户.
| 归档时间: |
|
| 查看次数: |
6844 次 |
| 最近记录: |