I have an arraylist of all folders and files where I want to get the ACL off. Everything runs well in my Foreach loop.
But for one odd reason it throws:
Get-Acl : Illegal characters + CategoryInfo : NotSpecified: (:) [Get-Acl], ArgumentException + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.GetAclCommand
When I run the get-acl manual with the 'faulty' path, I get the ACL. My code is:
$ACL = get-acl -LiteralPath "$Path" | select -ExpandProperty access | select IdentityReference
$Result = Compare-Object -ReferenceObject $ACLListAccess -DifferenceObject $ACL -Property Access -PassThru
if ($Result.count -ne 0)
{
$ExplicitTest = get-acl -LiteralPath "$Path" | select -ExpandProperty access
if ($ExplicitTest.IsInherited.count -ne $ACLListAccessFull.count -and $ExplicitTest.IsInherited -Like "*False*")
{
$WrongFolders.Add($Path) | Out-Null
}
}
The Path with the 'illegal character' is \mycompany.com\folders\Algemeen\Reme§ysen
$Path
actually expands to in the loop. – Alexander Obersht