only call set-acl if necessary

This commit is contained in:
Hans-Joachim Kliemeck 2015-10-26 10:20:14 +01:00
parent 3a5d4576c6
commit 45249fb042

View file

@ -111,23 +111,23 @@ Try {
$acl = Get-Acl $file.FullName
If ($acl.getOwner([System.Security.Principal.SecurityIdentifier]) -ne $objUser) {
Set-Attr $result "changed" $true;
}
$acl.setOwner($objUser)
Set-Acl $file.FullName $acl
Set-Attr $result "changed" $true;
}
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) {
Set-Attr $result "changed" $true;
}
$acl.setOwner($objUser)
Set-Acl $file.FullName $acl
Set-Attr $result "changed" $true;
}
}
}
}