Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
# 現在のユーザーリストを表示
PS C:\Users\Administrator> Get-ADUser -Filter * | Format-Table DistinguishedName
DistinguishedName
-----------------
CN=Administrator,CN=Users,DC=srv,DC=world
CN=Guest,CN=Users,DC=srv,DC=world
CN=krbtgt,CN=Users,DC=srv,DC=world
CN=Server World,CN=Users,DC=srv,DC=world
# 例として [ADUser01] ユーザー追加
PS C:\Users\Administrator> New-ADUser ADUser01 `
-Surname ADUser01 `
-GivenName ADUser01 `
-DisplayName "AD User01" `
-EmailAddress "ADUser01@srv.world" `
-AccountPassword (ConvertTo-SecureString -AsPlainText "P@ssw0rd01" -Force) `
-ChangePasswordAtLogon $true `
-Enabled $true
# 確認
PS C:\Users\Administrator> Get-ADUser -Identity ADUser01
DistinguishedName : CN=ADUser01,CN=Users,DC=srv,DC=world
Enabled : True
GivenName : ADUser01
Name : ADUser01
ObjectClass : user
ObjectGUID : 3317faca-ccea-4ff8-8bc4-ab2e7e54c878
SamAccountName : ADUser01
SID : S-1-5-21-220755274-1434786659-4133053638-1106
Surname : ADUser01
UserPrincipalName :
# [OU] を指定して追加する場合は以下
PS C:\Users\Administrator> New-ADUser ADUser02 `
-Path "OU=Hiroshima,DC=srv,DC=world" `
-Surname ADUser02 `
-GivenName ADUser02 `
-DisplayName "AD User02" `
-EmailAddress "ADUser02@srv.world" `
-AccountPassword (ConvertTo-SecureString -AsPlainText "P@ssw0rd02" -Force) `
-ChangePasswordAtLogon $true `
-Enabled $true
# 既存ユーザーのパスワードをリセットする場合は以下
PS C:\Users\Administrator> Set-ADAccountPassword -Identity ADUser02 `
-NewPassword (ConvertTo-SecureString -AsPlainText "UserP@ssw0rd02" -Force) `
-Reset
# 既存ユーザーを削除する場合は以下
PS C:\Users\Administrator> Remove-ADUser -Identity "CN=Redstone,CN=Users,DC=srv,DC=world"
Confirm
Are you sure you want to perform this action?
Performing the operation "Remove" on target "CN=Redstone,CN=Users,DC=srv,DC=world".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): Y
|