重置重命名的管理员帐户的密码
我需要创建一个 .VBS 脚本来重置一大群计算机上的 Windows 本地管理员密码。我的问题是,出于安全原因,我们的一些网站已重命名管理员帐户。有没有人有一个脚本可以根据原始管理员帐户的 SID 更改管理员帐户的密码?
I need to create a .VBS script to reset the Windows local administrator password on a large group of computers. My problem is that some of our sites have renamed the administrator account for security reasons. Does anyone have a script which changes the password of the administrator account based on the SID of the original Administrator account?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
利用本地管理员的 SID 始终以 -500 结尾的事实:
Using the fact that local admin's SID always ends with -500:
有一个名为 LookupAccountName 的工具(带有源代码!),给定内置管理员的 SID 即可为您提供其名称。
您可能最终会编写 C++ 代码来相当好地完成这一任务。
There's a tool floating around somewhere called LookupAccountName (with source!) that given the SID of the builtin adminitrator will give you its name.
You're probably going to end up writing C++ code to pull this one off reasonably well.
就像 Joshua 所说,我不认为你只能使用 Windows 脚本主机来做到这一点,你可以使用它下载一些东西并执行它:
Like Joshua says, I don't think you can do this with windows scripting host only, you could use it download something and execute it:
@DmitryK 的回答很好,但我对这些东西一无所知。但我确实知道这种事情在 PowerShell 中通常更干净,所以我移植了它。
例如,整个
GetAdminName
函数可以这样写:(将
-ComputerName
选项添加到gwmi
调用中以在服务器上执行此操作。)其余部分变为:
(当然,根据需要应用适当的计算机名称。)
@DmitryK's answer is good, and I didn't know any of that stuff. But I do know that this sort of thing is usually cleaner in PowerShell, so I ported it.
For example, the whole
GetAdminName
function can be written:(Add the
-ComputerName
option to thegwmi
call to do this on a server.)The rest becomes:
(applying the appropriate computer name as needed, of course.)