Hello,
II receive following error in my sript: "set acl The security identifier is not allowed to be the owner of this object"
My script:
$name = Read-Host -Prompt "Enter Userame"
$user = "Domain\" + $name
$path = "E:\Pictures"
$path
if(Test-Path $path){Write-Host
$Rights = "Read, ReadAndExecute, ListDirectory"
$InheritSettings = "Containerinherit, ObjectInherit" #Controls how permissions are inherited by children
$PropogationSettings = "None" #Usually set to none but can setup rules that only apply to children.
$RuleType = "Allow" #Allow or Deny.
$acl = Get-Acl $path
$acl.SetAccessRuleProtection($True, $True)
$perm = $user, $Rights, $InheritSettings, $PropogationSettings, $RuleType
$rule = New-Object -TypeName System.Security.AccessControl.FileSystemAccessRule -ArgumentList $perm
$acl.SetAccessRule($rule)
$acl | Set-Acl -Path $path
Write-Host -ForegroundColor Green "OK!"
} else {write-host "Not ok"}
#########################################
The E: drive is a mounted vhdx. I checked the drive owner - "the current owner cannot be displayed"
I'll be thankful for helping me out.