Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Powershell在Active directory中添加用户_Powershell - Fatal编程技术网

如何使用Powershell在Active directory中添加用户

如何使用Powershell在Active directory中添加用户,powershell,Powershell,我是powershell新手,正在尝试使用powershell在active directory中添加用户,但由于某些原因,我无法在active directory的新广告上使用tab complete,我已在具有管理员权限的windows 7客户端上以及DC本身上试过。有人能帮我一下吗?对不起,代码的格式很好,只有简短的注释。不过我希望这能有所帮助 下面的代码假设您在非DC服务器上。不确定这是否能在客户端机器上工作,如Windows7 导入服务器管理器模块和加载项远程AD功能 # import

我是powershell新手,正在尝试使用powershell在active directory中添加用户,但由于某些原因,我无法在active directory的新广告上使用tab complete,我已在具有管理员权限的windows 7客户端上以及DC本身上试过。有人能帮我一下吗?

对不起,代码的格式很好,只有简短的注释。不过我希望这能有所帮助

下面的代码假设您在非DC服务器上。不确定这是否能在客户端机器上工作,如Windows7

导入服务器管理器模块和加载项远程AD功能

# import the server manager
Import-Module ServerManager

#add in remote AD features
Add-WindowsFeature RSAT-AD-powerShell,RSAT-AD-AdminCenter

#list PS providers (one of which should be ActiveDirectory)
Get-PSProvider
…假设您使用的是具有intellisense的PowerShell版本,则这将为您提供intellisense

要创建新用户

#create a new user
New-ADUser –Name "John Smith" –SamAccountName "john.smith" –Description "Sales Manager" –Department "Sales" –EmployeeID "45896" –Path "ou=users,ou=sales,dc=test,dc=local" –Enabled $true
当我需要创建和探索广告用户时,我以电子方式草草记下的一些其他代码

#set location to AD
cd AD:

#list available options
dir

#explore the domain (replace DCNAME with domain)
cd 'DC=DCNAME,DC=local'

#back up
cd ..

#explore users (replace DCNAME with domain)
cd 'CN=Users,DC=DCNAME,DC=local'

#look at a user
Get-ItemProperty -Path "CN=Test ADUser1"

#find specific user
Get-ADUser "TestADUser10"

#find wildcard
Get-ADUser -LDAPFilter "(SamAccountName=*Test*)"

#get help on the aduser command
Get-Help Get-ADUser -Full

你运行导入模块ActiveDirectory了吗?我也运行了,但是没有active directory模块。我正在运行PowerShell的2.0版,这是一个实时DC。因此,目前不允许升级到v3.0,只想知道如何实现这一点您运行的是哪个版本的服务器?windows server 2008 R2i通过GUI创建了一个测试用户,并分析了只有两个GUI屏幕,第一个屏幕,其中我们指定了第一个姓名和姓氏以及电子邮件,下一个屏幕是密码。是否有一行代码只用于创建简单的测试用户,而无需放入特殊的OU,或添加任何有关城市和描述的详细信息?中间代码部分New ADUser是否无法实现这一点?对不起,我现在不能查。