虚位以待(AD)
虚位以待(AD)
首页 > 脚本专栏 > Powershell > PowerShell添加本地账户脚本分享

PowerShell添加本地账户脚本分享
类别:Powershell   作者:码皇   来源:互联网   点击:

这篇文章主要介绍了PowerShell添加本地账户脚本分享,本文直接给出实现代码,需要的朋友可以参考下

脚本源码:

复制代码 代码如下:

$nt=[adsi]"WinNT://localhost"
$user=$nt.create("user","test")
$user.setpassword("password")
$user.setinfo()
Get-WmiObject -Class Win32_UserAccount -Filter "name = 'test'" | Set-WmiInstance -Argument @{PasswordExpires = 0}
$group=[ADSI]"WinNT://localhost/administrators,group"
$group.add("WinNT://localhost/test")

相关热词搜索: PowerShell 添加本地账户