mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 21:32:49 +00:00
only call set-acl if necessary
This commit is contained in:
committed by
Matt Clay
parent
700ca56c61
commit
9ba30d2cea
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user