動作しない、私はそれ以外の場合は、それを検索することはできません、検索およびグループのために文字列の一部を削除したいのですが、Replace()
/Remove()
が動作していません。文字列に置き換え()/(削除)
$RootPath = $Selection
$Folders = dir $RootPath | where {$_.PSIsContainer -eq $true}
try {
foreach ($Folder in $Folders) {
$ACLs = Get-Acl $Folder.FullName | ForEach-Object {
$_.Access
}
foreach ($ACL in $ACLs) {
if ($ACL.IdentityReference -notlike "Administrators" -and $ACL.IdentityReference - notlike "Creator Owner" - and $ACL.IdentityReference -notlike "BUILTIN\Administrators" -and $ACL.IdentityReference -notlike "NT AUTHORITY\SYSTEM" -and $ACL.IdentityReference -notlike "System") {
$strAcl = $ACL.IdentityReference
# value is for instance GESCOEUROPE\GR_G-FCASB-INT-ALL
}
}
}
$strNames = $strAcl.Replace("GESCOEUROPE\", "")
# or:
#$strNames = $strAcl.Remove(0, 12)
$strUsers = Get-ADGroupMember -Identity $strNames -Recursive |
Get-ADUser -Property DisplayName |
Select Name |
Sort-Object Name
$OutInfo = $Folder.FullName + "," + $trAcl + $strUsers
$OutInfo | Select-Object -Unique
Add-Content -Value $OutInfo -Path $OutFile | Sort-Object -Unique
} catch [System.IO.IOException] {
}
}
を試してみてください:あなたのコードは、複数のフォルダを超えると、そのACLをそれぞれをループが、唯一のこれまで '$ strAcl'で_single_値を保存します。 – mklement0