Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

PowerShell imports AD domain users in bulk

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

For Windows server operation and maintenance staff, learning Powershell can greatly reduce their workload and improve efficiency.

Here is a problem I encountered in my work. There are 50 interns in the company, so I need to create an AD account for these 50 users. It is conceivable that it is a waste of time and time to operate one by one through the graphical interface.

Energetically, then when you learn to use Powershell, you can enter the information of these 50 people into the excel table, and then import it at one time using Powershell. Isn't it convenient to share the commands below?

Command: Import-Csv 'C:\ New\ AddADUser.csv' | ForEach-Object {New-ADUser-SamAccountName $. SamAccountName-Surname $. Surname-GivenName $. GivenName-Name $. Name-UserPrincipalName $. UserPrincipalName-DisplayName $. DisplayName-Description $. Description-Path $. Path-AccountPassword (ConvertTo-SecureString-AsPlainText $_. AccountPassword-Force)-Enabled 1-ChangePasswordAtLogon 1}

CSV template layout:

Note: CSV should be saved in UTF-8, otherwise Chinese will be garbled. You should be clear about the parameters corresponding to the template and don't fill in the template incorrectly. Enable 1, the number 1 indicates that the account is enabled, ChangePasswordAtLogon 1, and the number 1 indicates that the password needs to be changed the next time you log in. If the number is changed to 0, the account is disabled, and the next login does not need to change the password.

Import the effect drawing:

The tests are all in the virtual machine environment, no problem is running in the production environment.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report