# 現在の OU リストを表示
PS C:\Users\Administrator> Get-ADOrganizationalUnit -Filter * | Format-Table DistinguishedName
DistinguishedName
-----------------
OU=Domain Controllers,DC=srv,DC=world
OU=Hiroshima,DC=srv,DC=world
# 例として [Hiroshima] の配下に [Development01] を追加
PS C:\Users\Administrator> New-ADOrganizationalUnit Development01 `
-Path "OU=Hiroshima,DC=srv,DC=world" `
-ProtectedFromAccidentalDeletion $True
# 確認
PS C:\Users\Administrator> Get-ADOrganizationalUnit -Filter * | Format-Table DistinguishedName
DistinguishedName
-----------------
OU=Domain Controllers,DC=srv,DC=world
OU=Hiroshima,DC=srv,DC=world
OU=Development01,OU=Hiroshima,DC=srv,DC=world
# [ProtectedFromAccidentalDeletion $True] で登録した OU を削除する場合は以下
# (GUI 上の [誤って削除されないようにオブジェクトを保護する] オプションが有効)
# 一旦、無効化した後に削除する
PS C:\Users\Administrator> Set-ADOrganizationalUnit `
-Identity "OU=Development01,OU=Hiroshima,DC=srv,DC=world" `
-ProtectedFromAccidentalDeletion $false
PS C:\Users\Administrator> Remove-ADOrganizationalUnit -Identity "OU=Development01,OU=Hiroshima,DC=srv,DC=world"
Confirm
Are you sure you want to perform this action?
Performing the operation "Remove" on target "OU=Development01,OU=Hiroshima,DC=srv,DC=world".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): Y
# [New-ADOrganizationalUnit] オプション一覧
PS C:\Users\Administrator> Get-Help New-ADOrganizationalUnit
NAME
New-ADOrganizationalUnit
SYNOPSIS
Creates a new Active Directory organizational unit.
SYNTAX
New-ADOrganizationalUnit [-Name] <String> [-AuthType {Negotiate | Basic}] [-City <String>] [-Country <String>] [-Cr
edential <PSCredential>] [-Description <String>] [-DisplayName <String>] [-Instance <ADOrganizationalUnit>] [-Manag
edBy <ADPrincipal>] [-OtherAttributes <Hashtable>] [-PassThru] [-Path <String>] [-PostalCode <String>] [-ProtectedF
romAccidentalDeletion <Boolean>] [-Server <String>] [-State <String>] [-StreetAddress <String>] [-Confirm] [-WhatIf
] [<CommonParameters>]
.....
.....
|