Fix so it only deletes users that exist

pull/7861/head
Paul Durivage 11 years ago
parent 08c0b7e66e
commit 6dd9434707

@ -86,18 +86,23 @@ 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
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
}

Loading…
Cancel
Save