본문 바로가기

Microsoft/Windows Server 2008

Powershell - Create User Account

1. 새로운 사용자 생성

1) New-ADUser –Name "John Smith" -UserPrincipalName "John.smith@contoso.com" –SamAccountName JohnS –DisplayName "John Smith" –Title "Account Manager" –Enabled $true –ChangePasswordAtLogon $true -AccountPassword (ConvertTo-SecureString "p@ssw0rd" -AsPlainText -force) -PassThru

 

 

 

2) New-ADUser -Name Chris.Kim  -Path "ou=User Accounts,dc=contoso,dc=com" -AccountPassword (ConvertTo-SecureString "p@ssw0rd" -AsPlainText -force) -Enabled 1 -ChangePasswordAtLogon 1 -City Seoul -Company ITbank -Department "Sales" -Description "Sales Manager" -DisplayName "Chris Kim" -Division "David" -EmailAddress "Chris.kim@contoso.com" -EmployeeID "EmployeeID" -EmployeeNumber "EmployeeNumber" -Fax "02-789-7896" -GivenName Kim -HomeDirectory \\am-den-srv1\Chris.kim -HomePage "http://paraclete.tistory.com" -HomePhone 02-987-9874 -Instance "ADUser" -LogonWorkstations "am-den-srv1" -Manager "Administrator" -MobilePhone "010-789-7896" -Office "HQ" -OfficePhone "02-456-4563" -Organization "Economic" -PasswordNeverExpires $false -PasswordNotRequired $flase -PostalCode "123-321" -SamAccountName Chris.Kim -StreetAddress "321-1" -Surname "jr." -Title "Manager" -UserPrincipalName "Chris.kim@contoso.com" -PassThru

 

 

2. 새로운 그룹 생성

New-ADGroup -Name "Account Managers" -SamAccountName AcctMgrs -GroupScope Global -GroupCategory Security -Description "Account Managers Group" –PassThru

 

3. 새로운 조직단위 생성

New-ADOrganizationalUnit -Name AccountsDepartment -ProtectedFromAccidentalDeletion $true  -PassThru

 

4. 이름 기반으로 필터링하여 사용자 찾기

get-ADUser -filter {name -like "John*"}

## Gets all the users whose name starts with John

 

5. 특정 그룹(AcctMgrs)에 사용자 추가

Add-ADGroupMember -Identity AcctMgrs -Members JohnS

 

6. 특정 그룹에 소속원 확인하기

Get-ADGroupMember -Identity AcctMgrs

 

7. 사용자가 소속된 모든 그룹 정보

Get-ADPrincipalGroupMembership -Identity JohnS

 

8. 어떤 계정에 대한 토큰 그룹 정보

Get-ADAccountAuthorizationGroup -Identity JohnS

 

9. 특정 사용자 계정 잠금 해제

Unlock-ADAccount -Identity JohnS

 

10. 로컬 컴퓨터가 소속괸 forest  정보

Get-ADForest -Current LocalComputer

 

11. 로그온된 사용자의 도메인 정보

Get-ADDomain -Current LoggedOnUser

 

12. 모든 DC 정보 찾기

 Get-ADDomainController -Filter { name -like "*" }