【发布时间】:2019-03-05 08:58:57
【问题描述】:
我正在尝试创建一个 Powershell 脚本,该脚本仅从文件夹权限设置中打印出某些 AD 组。但是由于某种原因,Powershell 无法识别 StartsWith 函数。
("C:\folder" | get-acl).Access | ForEach-Object { if (($_.IdentityReference).StartsWith("sl_test")) { continue }; $_ }
当我运行它时,每个 foreach 对象都会出现类似的错误:
方法调用失败,因为 [System.Security.Principal.NTAccount] 不包含名为“StartsWith”的方法。 在 C:\temp\test.ps1:1 char:56 + ("C:\folder" | get-acl).Access | ForEach-Object { if (($_.IdentityReference).St ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : MethodNotFound
关于如何让它工作的任何建议?
【问题讨论】:
标签: powershell startswith