간단 설명
Organization Unit 을 지우기 위해
Protect object from accidental deletion 의 체크박스를 제거해야 합니다.
(없다면 제거하는 방법 건너뛰면 됩니다.)
한 두개 정도는 마우스로 직접 해도 됩니다.
하지만, Organization Unit 이 많을 경우
반복문을 통하여 한번에 작업할 수 있는 이점이 있습니다.
그렇기 때문에 제어하는 방법부터 먼저 확인 합니다.
Protect object from accidental deletion 제거하기
Get-ADOrganizationalUnit -Filter * -SearchBase "위치" | Set-ADObject -ProtectedFromAccidentalDeletion $false -Verbose
여기서 위치는 " OU=이름 , OU=이름 , DC=도메인 , DC=도메인 " 입니다.
Organization Unit 제거하기
Remove-ADOrganizationalUnit -Identity "위치" -Recursive
그림과 설명
Protect object from accidental deletion 의 체크박스를 제거하지 않고
OU 제거 시도시
Remove-ADOrganizationalUnit -Identity "위치" -Recursive
아래와 같은 에러 코드가 나옵니다.
Remove-ADOrganizationalUnit : Access is denied
이 부분 제거를 위한 코드는 아래와 같습니다.
Get-ADOrganizationalUnit -Filter * -SearchBase "위치" | Set-ADObject -ProtectedFromAccidentalDeletion $false -Verbose
Get-ADOrganizationalUnit (ActiveDirectory)
Use this topic to help manage Windows and Windows Server technologies with Windows PowerShell.
docs.microsoft.com
Get-ADOrganizationalUnit
[-AuthType <ADAuthType>]
[-Credential <PSCredential>]
-Filter <String>
[-Properties <String[]>]
[-ResultPageSize <Int32>]
[-ResultSetSize <Int32>]
[-SearchBase <String>]
[-SearchScope <ADSearchScope>]
[-Server <String>]
[<CommonParameters>]
-Filter * -SearchBase를 사용합니다.
먼저 어디에 있는지 위치를 정해주는 거 같습니다.
그리고 | 를 사용하여 다음 명령어를 입력합니다.
Set-ADObject -ProtectedFromAccidentalDeletion $false -Verbose
여기서 $ 뒤에 true 로 변경하면 체크박스가 표시되고
$false 의미는 체크박스를 제거하는 것입니다.
Set-ADObject (ActiveDirectory)
Use this topic to help manage Windows and Windows Server technologies with Windows PowerShell.
docs.microsoft.com
Set-ADObject
[-WhatIf]
[-Confirm]
[-Add <Hashtable>]
[-AuthType <ADAuthType>]
[-Clear <String[]>]
[-Credential <PSCredential>]
[-Description <String>]
[-DisplayName <String>]
[-Identity] <ADObject>
[-Partition <String>]
[-PassThru]
[-ProtectedFromAccidentalDeletion <Boolean>]
[-Remove <Hashtable>]
[-Replace <Hashtable>]
[-Server <String>]
[<CommonParameters>]
[-ProtectedFromAccidentalDeletion <Boolean>] 를 보면
Boolean 값이기 때문에 True 또는 False 값을 주었습니다.
그럼 Protect object from accidental deletion 값이 제거되어 삭제가 가능합니다.
그리고 삭제를 위해
Remove-ADOrganizationalUnit (ActiveDirectory)
Use this topic to help manage Windows and Windows Server technologies with Windows PowerShell.
docs.microsoft.com
Remove-ADOrganizationalUnit
[-WhatIf]
[-Confirm]
[-AuthType <ADAuthType>]
[-Credential <PSCredential>]
[-Identity] <ADOrganizationalUnit>
[-Partition <String>]
[-Recursive]
[-Server <String>]
[<CommonParameters>]
Remove-ADOrganizationalUnit 에
[-Identity] <ADOrganizationalUnit> 를 사용합니다.
그럼 아래와 같은 명렁어를 입력합니다.
Remove-ADOrganizationalUnit -Identity "위치" -Recursive
그럼 정상적으로 삭제가 된 것을 볼 수 있습니다.
'PowerShell > ActiveDirectory' 카테고리의 다른 글
[Active Directory] Organizational Unit 만들기 (UI 버전) (0) | 2020.10.26 |
---|