only call set-acl if necessary
This commit is contained in:
parent
3a5d4576c6
commit
45249fb042
1 changed files with 6 additions and 6 deletions
|
@ -111,23 +111,23 @@ Try {
|
||||||
$acl = Get-Acl $file.FullName
|
$acl = Get-Acl $file.FullName
|
||||||
|
|
||||||
If ($acl.getOwner([System.Security.Principal.SecurityIdentifier]) -ne $objUser) {
|
If ($acl.getOwner([System.Security.Principal.SecurityIdentifier]) -ne $objUser) {
|
||||||
|
$acl.setOwner($objUser)
|
||||||
|
Set-Acl $file.FullName $acl
|
||||||
|
|
||||||
Set-Attr $result "changed" $true;
|
Set-Attr $result "changed" $true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$acl.setOwner($objUser)
|
|
||||||
Set-Acl $file.FullName $acl
|
|
||||||
|
|
||||||
If ($recurse) {
|
If ($recurse) {
|
||||||
$files = Get-ChildItem -Path $path -Force -Recurse
|
$files = Get-ChildItem -Path $path -Force -Recurse
|
||||||
ForEach($file in $files){
|
ForEach($file in $files){
|
||||||
$acl = Get-Acl $file.FullName
|
$acl = Get-Acl $file.FullName
|
||||||
|
|
||||||
If ($acl.getOwner([System.Security.Principal.SecurityIdentifier]) -ne $objUser) {
|
If ($acl.getOwner([System.Security.Principal.SecurityIdentifier]) -ne $objUser) {
|
||||||
|
$acl.setOwner($objUser)
|
||||||
|
Set-Acl $file.FullName $acl
|
||||||
|
|
||||||
Set-Attr $result "changed" $true;
|
Set-Attr $result "changed" $true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$acl.setOwner($objUser)
|
|
||||||
Set-Acl $file.FullName $acl
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue