我有一个所有文件夹和文件的列表列表,我希望关闭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
检查'$ Path'实际扩展到循环中。 –
当我做写主机时,它是正确的。它看起来像在变异动物本身中被处理过吗? – user1000584