1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fix so it only deletes users that exist

This commit is contained in:
Paul Durivage 2014-06-19 16:24:57 -05:00
parent 08c0b7e66e
commit 6dd9434707

View file

@ -86,17 +86,22 @@ if ($state -eq 'present') {
Create-User $username $password
}
$result.changed = $true
$user_obj = Get-User $username
}
catch {
Fail-Json $result $_.Exception.Message
}
}
else {
# Remove user
try {
Delete-User $bob
$result.changed = $true
if ($user_obj.GetType) {
Delete-User $user_obj
$result.changed = $true
}
else {
Set-Attr $result "msg" "User '$username' was not found"
}
}
catch {
Fail-Json $result $_.Exception.Message