728x90
728x90
AD OU 생성
New-ADOrganizationalUnit -Name "honglab_ou" -Path "OU=DOMAIN,DC=DOMAIN,DC=com"
AD User 생성
New-ADUser -DisplayName "honglab" -AccountPassword $(ConvertTo-SecureString -AsPlainText "Password#1" -Force) -Name "honglab" -EmailAddress "honglab97@gmail.com" -GivenName "HaeJang" -Surname "Hong" -UserPrincipalName "honglab@DOMAIN.com" -ChangePasswordAtLogon $True -Path "OU=honglab_ou,OU=DOMAIN,DC=DOMAIN,DC=com"
CSV에서 바로 User 생성
Import-Csv .\ad_user.csv | foreach-object{
New-ADUser -Name $_.Full_Name -EmailAddress $_.Email -AccountPassword (ConvertTo-SecureString $_.Password -AsPlainText -force) -DisplayName $_.Full_Name -GivenName $_.First_Name -Path $_.Path -Surname $_.Last_Name -UserPrincipalName $_.Logon_Name -ChangePasswordAtLogon $True
}
ad_user.csv
Batch 사용해서 일괄적으로 추가하기
run_ps.bat
@echo off
Powershell.exe -executionpolicy remotesigned -File .\add_ad_user.ps1
pause
add_ad_user.ps1
New-ADOrganizationalUnit -Name "honglab_ou" -Path "OU=DOMAIN,DC=DOMAIN,DC=com"
Import-Csv .\ad_user.csv | foreach-object{
New-ADUser -Name $_.Full_Name -EmailAddress $_.Email -AccountPassword (ConvertTo-SecureString $_.Password -AsPlainText -force) -DisplayName $_.Full_Name -GivenName $_.First_Name -Path $_.Path -Surname $_.Last_Name -UserPrincipalName $_.Logon_Name -ChangePasswordAtLogon $True
}
Ref
https://community.spiceworks.com/topic/541380-adding-users-via-new-aduser-and-a-csv-file
728x90
728x90
'공부 > Windows' 카테고리의 다른 글
[Active Directory] LDAP userAccountControl 속성값 (0) | 2024.02.01 |
---|---|
[Active Directory] hosts file을 AD로 제공하는 방법 (정방향 조회 영역 추가) (0) | 2022.07.30 |
[Active Directory] Proxy Setting하기 (AWS WorkSpaces Client) (0) | 2021.09.03 |
[Windows] CMD/PowerShell로 User 생성, 그룹에 추가하기 (0) | 2021.06.15 |
[Batch script] @echo off 란? (0) | 2021.05.03 |
댓글