使用PowerShell创建本地用户(Windows Vista) [英] Create local user with PowerShell (Windows Vista)
本文介绍了使用PowerShell创建本地用户(Windows Vista)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我最近安装了PowerShell,开始寻找的第一件事就是如何创建新用户。找了一段时间后,我仍然找不到。
我对Linux上的bash有一点经验,发现它非常有效。在这里创建用户很简单。
是否有一种简便的内置方法来使用PowerShell创建本地用户?
I've installed PowerShell recently and one of the first things I started looking for was how to create a new user. After looking for some time I still haven't found this. I have a little experience in bash on linux and find it very effective. Creating users there is trivial. Is there an easy\built-in way to create a local user with PowerShell?
谢谢。
推荐答案
您可以使用本地主机的 ADSI :
You can use the localhost's ADSI:
function create-account ([string]$accountName = "testuser") {
$hostname = hostname
$comp = [adsi] "WinNT://$hostname"
$user = $comp.Create("User", $accountName)
$user.SetPassword("Password1")
$user.SetInfo()
}
这篇关于使用PowerShell创建本地用户(Windows Vista)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文