Simple script is producing blank response

So I have this sript, the Get-ChildItem produces a list with a header name of “Name” and entries similar to Firstname LastName with a space between the two.

Everything runs without producing any errors but my $Results export is always empty even though I know there should be results. If I manually replace the $folderp with a known name it works!

Help Please….

Get-ChildItem -LiteralPath "\serverusers" -Force| Where-Object {$_.PSIsContainer} | Select -Property name |Export-CSV c:folderdrive_name.csv -NoTypeInformation $foldern = Import-csv c:folderdrive_name.csv $Results = foreach ($path in $foldern) { $folderp = $path.Name Get-ADuser -Filter 'SamAccountName -eq "$folderp"' -Properties * | Select -Property Name,SamAccountName,LastLogonDate } $Results | Export-csv c:folderresult.csv -NoTypeInformation 

submitted by /u/TonyD1018
[link] [comments]

Leave a Reply