Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
# [ADUser02] ユーザーを UNIX 属性を指定して新規追加
# [-OtherAttributes] に最低限必要な属性をハッシュテーブルで指定
PS C:\Users\Administrator> New-ADUser ADUser02 `
-Surname ADUser02 `
-GivenName ADUser02 `
-DisplayName "AD User02" `
-EmailAddress "ADUser02@srv.world" `
-AccountPassword (ConvertTo-SecureString -AsPlainText "P@ssw0rd02" -Force) `
-ChangePasswordAtLogon $true `
-Enabled $true `
-OtherAttributes @{uidNumber="5001"; gidNumber="100"; loginShell="/bin/bash"; unixHomeDirectory="/home/ADUser02"}
# 確認
PS C:\Users\Administrator> Get-ADUser -Identity ADUser02 -Properties * | Out-String -Stream | Select-String "uidNumber","gidNumber","loginShell","unixHomeDirectory"
gidNumber : 100
loginShell : /bin/bash
uidNumber : 5001
unixHomeDirectory : /home/ADUser02
# 既存ユーザー [ADUser01] ユーザーに UNIX 属性追加
PS C:\Users\Administrator> Get-ADUser -Identity ADUser01
DistinguishedName : CN=AD User01,CN=Users,DC=srv,DC=world
Enabled : True
GivenName : User01
Name : AD User01
ObjectClass : user
ObjectGUID : 457aa6c8-8c5d-4c00-92c0-14b5d43de16b
SamAccountName : ADUser01
SID : S-1-5-21-1322887480-1777281493-1913265488-1104
Surname : AD
UserPrincipalName : ADUser01@srv.world
# [-Add] に最低限必要な属性をハッシュテーブルで指定
PS C:\Users\Administrator> Set-ADUser -identity "CN=AD User01,CN=Users,DC=srv,DC=world" `
-Add @{uidNumber="5000"; gidNumber="100"; loginShell="/bin/bash"; unixHomeDirectory="/home/ADUser01"}
PS C:\Users\Administrator> Get-ADUser -Identity ADUser01 -Properties * | Out-String -Stream | Select-String "uidNumber","gidNumber","loginShell","unixHomeDirectory"
gidNumber : 100
loginShell : /bin/bash
uidNumber : 5000
unixHomeDirectory : /home/ADUser01
|