diff --git a/changelogs/fragments/44500-win_domain_computer.yaml b/changelogs/fragments/44500-win_domain_computer.yaml new file mode 100644 index 00000000000..4fbe62111ba --- /dev/null +++ b/changelogs/fragments/44500-win_domain_computer.yaml @@ -0,0 +1,2 @@ +bugfixes: +- win_domain_computer - fixed deletion of computer active directory object that have dependent objects (https://github.com/ansible/ansible/pull/44500) diff --git a/lib/ansible/modules/windows/win_domain_computer.ps1 b/lib/ansible/modules/windows/win_domain_computer.ps1 index 9f766cb9a99..ed37aacfbab 100644 --- a/lib/ansible/modules/windows/win_domain_computer.ps1 +++ b/lib/ansible/modules/windows/win_domain_computer.ps1 @@ -129,8 +129,9 @@ Function Add-ConstructedState($desired_state) { # ------------------------------------------------------------------------------ Function Remove-ConstructedState($initial_state) { Try { - Remove-ADComputer ` - -Identity $initial_state.name ` + Get-ADComputer $initial_state.name ` + | Remove-ADObject ` + -Recursive ` -Confirm:$False ` -WhatIf:$check_mode } Catch {