diff --git a/lib/ansible/modules/extras/windows/win_owner.ps1 b/lib/ansible/modules/extras/windows/win_owner.ps1 index eb69e744e6..0623f2b17a 100644 --- a/lib/ansible/modules/extras/windows/win_owner.ps1 +++ b/lib/ansible/modules/extras/windows/win_owner.ps1 @@ -111,23 +111,23 @@ Try { $acl = Get-Acl $file.FullName If ($acl.getOwner([System.Security.Principal.SecurityIdentifier]) -ne $objUser) { + $acl.setOwner($objUser) + Set-Acl $file.FullName $acl + Set-Attr $result "changed" $true; } - $acl.setOwner($objUser) - Set-Acl $file.FullName $acl - If ($recurse) { $files = Get-ChildItem -Path $path -Force -Recurse ForEach($file in $files){ $acl = Get-Acl $file.FullName If ($acl.getOwner([System.Security.Principal.SecurityIdentifier]) -ne $objUser) { + $acl.setOwner($objUser) + Set-Acl $file.FullName $acl + Set-Attr $result "changed" $true; } - - $acl.setOwner($objUser) - Set-Acl $file.FullName $acl } } }