0
votes

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

1
Check what $Path actually expands to in the loop.Alexander Obersht
When i do write-host it is correct. It looks like in the variabel itself it is handled otherwise?user1000584

1 Answers

0
votes

Sorry, cannot repro your problem and comment does not allow me to paste this

D:\temp\a> get-acl .\aaa§bbb
    Directory: D:\temp\a
Path                                                         Owner                                                        Access                                                      
----                                                         -----                                                        ------                                                      
aaa§bbb                                                      adil                                               BUILTIN\Administrators Allow  FullControl...

if you copy paste that character, do you also get 167?

C:\> [int][char]'§'
167