简体   繁体   English

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

[英]How to Add user in Active directory using Powershell

I am new to powershell and trying to add user in active directory using powershell, but for some reason I cannot tab complete on New-Ad for active directory, I have tried on windows 7 client with admin right also on DC itself. 我是Powershell的新手,并尝试使用Powershell在活动目录中添加用户,但由于某些原因,我无法在Active Directory的New-Ad上完成制表符的操作,因此我尝试在Windows 7客户端上同时在DC本身上以管理员身份进行尝试。 Can some one please help also what would be the code to do that? 有人可以帮忙吗,这样做的代码是什么?

Apologies non of the code is formatted nicely and only has terse comments. 不好意思的代码格式很好,只有简短的注释。 I hope it helps though. 我希望这会有所帮助。

The code below assumes you're on a non-DC server. 下面的代码假定您使用的是非DC服务器。 Not sure if this will work on a client machine, like Windows 7. 不知道这是否可以在客户端计算机上运行,​​例如Windows 7。

Import the server manager module and add in remote AD features... 导入服务器管理器模块并添加远程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

...this should give you intellisense, assuming you're on a version of PowerShell that has intellisense. ...这应该给您带来智能感知的能力,假设您使用的是具有智能感知功能的PowerShell。

To create a new user... 要创建新用户...

#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

Some other code that I scribbled down electronically, when I needed to create and explore AD users. 当我需要创建和浏览AD用户时,我会用电子方式编写其他一些代码。

#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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Powershell在Active Directory组中添加用户 - How to add user in a Active directory Group using powershell 如何使用 Powershell 添加用户并添加到 Active Directory 中? - How can I add a user and add in Active Directory with Powershell? 如何使用PowerShell远程处理从C#向Active Directory用户添加图像? - How to add image to Active Directory user from C# using PowerShell remoting? 使用Powershell更新Active Directory中的Active Directory用户属性 - Updating Active Directory user properties in Active Directory using Powershell C#无法运行PowerShell脚本添加用户Active Directory - C# Can not run PowerShell script to add user Active Directory PowerShell 将用户添加到 Active Directory 中不同域的脚本 - PowerShell script to add user to different domain in Active Directory 如何基于用户选择类型powershell将用户添加到活动目录中的特定组中 - how to add users into a specific group in active directory based on the user selection type powershell PowerShell:如何将 1 个用户添加到多个 Active Directory 安全组 - 具有写入权限的安全组的安全选项卡 - PowerShell: How to add 1 user to multiple Active Directory Security Groups - Security tab of the security group with write permission 使用 powershell 将组添加到活动目录 - add groups to active directory with powershell 如何在用户的Active Directory中添加分散组? - How to add the distrubtion group in Active Directory for a user?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM