Corrected Get-adcomputer (#63093)
* Corrected Get-adcomputer Corrected Get-adcomputer on "Remove-ConstructedState" and "Set-ConstructedState" functions. resolved error: Unable to contact the server. This may be because this server does not exist, it is currently down, or it does not have the Active Directory Web Services running. * Update lib/ansible/modules/windows/win_domain_computer.ps1 Co-Authored-By: Daniel-Sanchez-Fabregas <33929811+Daniel-Sanchez-Fabregas@users.noreply.github.com> * Update win_domain_computer.ps1 changed "-credential $credential" to "@extra_args" (Line 115 and 150) corrected exception message (Line 122) * Added changelog fragment, minor code tweak
This commit is contained in:
parent
e74d397c01
commit
e77426dad3
2 changed files with 10 additions and 8 deletions
2
changelogs/fragments/win_domain_computer-credential.yaml
Normal file
2
changelogs/fragments/win_domain_computer-credential.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- win_domain_computer - Honour the explicit domain server and credentials when moving or removing a computer object - https://github.com/ansible/ansible/pull/63093
|
|
@ -112,14 +112,14 @@ Function Set-ConstructedState($initial_state, $desired_state) {
|
|||
If ($initial_state.distinguished_name -cne $desired_state.distinguished_name) {
|
||||
# Move computer to OU
|
||||
Try {
|
||||
Get-ADComputer -Identity $desired_state.name |
|
||||
Get-ADComputer -Identity $desired_state.name @extra_args |
|
||||
Move-ADObject `
|
||||
-TargetPath $desired_state.ou `
|
||||
-Confirm:$False `
|
||||
-WhatIf:$check_mode `
|
||||
@extra_args
|
||||
} Catch {
|
||||
Fail-Json -obj $result -message "Failed to move the AD object $($desired_state.name) to $($desired_state.ou) OU: $($_.Exception.Message)"
|
||||
Fail-Json -obj $result -message "Failed to move the AD object $($initial_state.distinguished_name) to $($desired_state.distinguished_name): $($_.Exception.Message)"
|
||||
}
|
||||
}
|
||||
$result.changed = $true
|
||||
|
@ -147,8 +147,8 @@ Function Add-ConstructedState($desired_state) {
|
|||
# ------------------------------------------------------------------------------
|
||||
Function Remove-ConstructedState($initial_state) {
|
||||
Try {
|
||||
Get-ADComputer $initial_state.name `
|
||||
| Remove-ADObject `
|
||||
Get-ADComputer -Identity $initial_state.name @extra_args |
|
||||
Remove-ADObject `
|
||||
-Recursive `
|
||||
-Confirm:$False `
|
||||
-WhatIf:$check_mode `
|
||||
|
|
Loading…
Reference in a new issue