Commit 6dd94347 by Paul Durivage

Fix so it only deletes users that exist

parent 08c0b7e6
...@@ -86,17 +86,22 @@ if ($state -eq 'present') { ...@@ -86,17 +86,22 @@ if ($state -eq 'present') {
Create-User $username $password Create-User $username $password
} }
$result.changed = $true $result.changed = $true
$user_obj = Get-User $username
} }
catch { catch {
Fail-Json $result $_.Exception.Message Fail-Json $result $_.Exception.Message
} }
} }
else { else {
# Remove user # Remove user
try { try {
Delete-User $bob if ($user_obj.GetType) {
$result.changed = $true Delete-User $user_obj
$result.changed = $true
}
else {
Set-Attr $result "msg" "User '$username' was not found"
}
} }
catch { catch {
Fail-Json $result $_.Exception.Message Fail-Json $result $_.Exception.Message
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment