Author Posts

October 1, 2015 at 10:10 am

Currently I am trying to export a list of VDI's last logon date to a .csv but I can't get it to work properly. This is what I currently am trying and I am a bit of a noob when it comes to scripting powershell in general.

Get-ADComputer -Filter 'Name -like "*VDI*"' -Properties * | FT Name, LastLogonDate -Autosize | select-object Name, LastLogonDate | export-csv -LiteralPath "C:\test.csv"

It won't give me the actual list from when I run this command in a /CSV Get-ADComputer -Filter 'Name -like "*VDI*"' -Properties * | FT Name, LastLogonDate -Autosize

Can anyone help me as to what I need to do exactly to get it to automatically output to a .CSV nicely? Any help would be much appreciated.


October 1, 2015 at 10:15 am

Get rid of the call to Format-Table (FT). This converts the data to an array of GroupStartData objects. Just stick with:

Get-ADComputer -Filter 'Name -like "*VDI*"' -Properties * | select-object Name, LastLogonDate | export-csv -LiteralPath "C:\test.csv"

October 1, 2015 at 10:16 am

Go to the Resource menu above and look at the free ebook "Powershell Gotchas". Your issue is this:

| FT Name, LastLogonDate -Autosize

Format-Table or Format-List stop the pipeline, so nothing goes beyond those commands. Remove the above from your command-line and you should be good to go.

October 1, 2015 at 10:17 am

Thanks. I knew it was just something easy, but as I said I am learning. That did it.

October 1, 2015 at 10:18 am

That's because you are doing your FT (format-table) before you select-object. FT is an output cmdlet. Once your data hits FT in the pipeline, FT sends the data to the console screen in a table format. No data is passed down the pipe to Select-Object or Export-CSV. You should take FT out completely and you should be good to go.

Get-ADComputer -Filter 'Name -like "*VDI*"' -Properties * | select-object Name, LastLogonDate | export-csv -LiteralPath "C:\test.csv"

October 1, 2015 at 10:19 am

Doh, I'm slow apparently! 😀

October 1, 2015 at 11:40 am


I've had times where I refresh the page, there are no responses and I only see my post. Later I'll look and there are like 15 posts in between my post. I feel your pain. 🙂

October 5, 2015 at 12:14 am

thank to this question..... i need to work on it....

Tableau Online Training
is good?