PowerShell:更改本地管理员密码

Bal*_*tar 5 powershell

登录$ComputerName为本地管理员Windows Server 2008 R2 SP1

这个脚本:

$admin=[adsi]("WinNT://" + $ComputerName + "/administrator, user")
$admin.psbase.invoke("SetPassword", $Password)
$admin.psbase.CommitChanges()
Run Code Online (Sandbox Code Playgroud)

本地运行抛出异常: Exception calling "Invoke" with "2" argument(s):"The network path was not found"

小智 1

还没有测试过这个,但我发现

\n\n
([adsi]\xe2\x80\x9cWinNT://<Local or Remote Computer Name>/<Username>\xe2\x80\x9d).SetPassword(\xe2\x80\x9c<Password>\xe2\x80\x9d)\n
Run Code Online (Sandbox Code Playgroud)\n\n

http://www.petri.co.il/how-to-change-user-password-with-powershell.htm

\n