【发布时间】:2014-09-10 21:01:34
【问题描述】:
(([datetime]::FromFileTime((Get-ADUser –Identity username -Properties "msDS-UserPasswordExpiryTimeComputed")."msDS-UserPasswordExpiryTimeComputed"))-(Get-Date)).Days
将输出直到 AD 帐户过期的时间量。但是,当我尝试通过设置一个等于它的变量来将它放在脚本中时,它会崩溃并快速关闭并且它不起作用。我不确定为什么。
编辑:
只在我的脚本中运行这个命令,我得到一个错误:
$Expiration = (([datetime]::FromFileTime((Get-ADUser –Identity 'MyTestUser' -Properties "msDS-UserPasswordExpiryTimeComputed")."msDS-UserPasswordExpiryTimeComputed"))-(Get-Date)).Days
错误:
At C:\Users\ajstepanik\Desktop\test.ps1:1 char:161
+ ... iryTimeComputed"))-(Get-Date)).Days
+ ~~~~~~~~~~~~~~~~~~~~
The string is missing the terminator: ".
At C:\Users\ajstepanik\Desktop\test.ps1:1 char:181
+ ... Get-Date)).Days
+ ~
Missing closing ')' in expression.
At C:\Users\ajstepanik\Desktop\test.ps1:1 char:181
+ ... Get-Date)).Days
+ ~
Missing ')' in method call.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordEx
ception
+ FullyQualifiedErrorId : TerminatorExpectedAtEndOfString
【问题讨论】:
标签: powershell active-directory