Hello and thanks for your patience. This should be an easy one - and as you have said you before you won't learn powershell until you force yourself to write a script you need in PS instead of going back to your old ways.
I am trying to use a text file with a list of users, query AD for the fields needed and export the information to a CSV that I can import into Excel. I am using the code below but the contents of the .csv file are just 3 lines of #Type String, "Length", "0". When I check the variable $MyTable I see the results, mixed in with the field names (which I figured I could clean up in Excel if I can strip it out in the script).
Any suggestions appreciated. (FYI - I have tried with and without the Format-Table -HideTableHeaders as well)
$MyTable="" $Users =Get-Content"h:\Scripts\PowerShell\ADUsers\Test.txt" ForEach ($MyUserin$Users) $MyTable|Export-Csv-PATH".\AdUserDump.csv"
{
$MyTable += Get-QADUser -SearchRoot 'MyDomain.org'-samaccountname $MyUser | select lastname,firstname,logonname,whencreated,lastlogontimestamp, AccountIsDisabled | sort-object -property lastlogontimestamp | Format-Table -HideTableHeaders
}