Windows 2012服务器中的本地用户凭据检查

时间:2016-12-28 11:13:45

标签: powershell powershell-v3.0 credentials windows-server-2012-r2 powershell-v4.0

我正在尝试使用以下代码验证本地用户凭据:

Add-Type -AssemblyName System.DirectoryServices.AccountManagement
$DS = New-Object System.DirectoryServices.AccountManagement.PrincipalContext('machine',$ComputerName)
$status=$DS.ValidateCredentials($UserName, $Password)

我收到以下错误:

Exception calling "ValidateCredentials" with "2" argument(s): "The specified network name is no longer available.
"
At line:1 char:1
+ $ds.ValidateCredentials('User','Password')
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : PrincipalOperationException

请帮我解决这个问题。

提前致谢

注意:我没有在所有机器上收到此错误。在87台机器中,我仅在12台机器中出现此错误。

1 个答案:

答案 0 :(得分:0)

启动'服务器'服务修复了问题