2015-09-25 50 views
0

我有一个所有文件夹和文件的列表列表,我希望关闭ACL。 一切都在我的Foreach循环中运行良好。Get-ACL -Literalpath引发路径中的非法字符

但一个奇怪的原因,它抛出:

获取的ACL:非法字符 + CategoryInfo:NotSpecified:(:) [获取的ACL],ArgumentException的 + FullyQualifiedErrorId信息:System.ArgumentException,微软。 PowerShell.Commands.GetAclCommand

当我运行带有'错误'路径的get-acl手册时,我得到ACL。 我的代码是:

   $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 
        } 
        } 

与“非法字符”的路径是 \ mycompany.com \文件夹\ Algemeen \Reme§ysen

+1

检查'$ Path'实际扩展到循环中。 –

+0

当我做写主机时,它是正确的。它看起来像在变异动物本身中被处理过吗? – user1000584

回答

0

对不起,不能瑞普你的问题和评论不允许我贴这个

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

如果你复制粘贴该字符,你也得到167?

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

是的,它是一样的东西。当我在另一台电脑上运行它时,它就像魅力一样。当我做$ Path | out-file在计算机上出现错误,然后出现不同的字符§。 PowerShell中的$ Outputencoding是一样的。当我在这台机器上运行chcp时,它与我的另一台机器不同。当我运行chcp 850(这是它工作的机器上的值)时,问题依然存在。 – user1000584

相关问题