$files = Get-ChildItem c:\The obvious problem is the first statement. The obvious question remains: how do I walk through a drive recursively without running out of memory? Something of a Get-ChildItem that would execute code on the target without needing to first put the whole structure in memory?
foreach $file in $files {
'Do something here
}
However, there is an important difference. When you pipe multiple objects to a command, Windows PowerShell sends the objects to the command one at a time. When you use a command parameter, the objects are sent as a single array object.So maybe something like
Get-ChildItem c:\ | do-thing
$outfile = "C:\AD_group_permissions_found.txt"
$files = Get-ChildItem -recurse j:\
foreach ($file in $files) {
Write-Host "Scanning " $file.FullName
$a = Get-Acl $file.FullName
$aces =$a.GetAccessRules($true, $false, [System.Security.Principal.NTAccount])
foreach ($ace in $aces) {
if ($ace.IdentityReference.ToString() -match "^DOMAIN\\GROUP") {
$file.FullName + ": " + $ace.IdentityReference.ToString() | Add-Content $outfile
}
}
}You are not logged in, either login or create an account to post comments
I'm not sure how to implement that in powershell though.
posted by demiurge at 8:31 AM on October 8, 2009