From ce0909035bacf09adeb5ed29aaae46c7f89d0130 Mon Sep 17 00:00:00 2001 From: Paul Durivage Date: Thu, 19 Jun 2014 16:24:57 -0500 Subject: [PATCH] Fix so it only deletes users that exist --- windows/win_user.ps1 | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/windows/win_user.ps1 b/windows/win_user.ps1 index 003579104da..1b7bec26f0d 100644 --- a/windows/win_user.ps1 +++ b/windows/win_user.ps1 @@ -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