# Output Powershell to Text File problem

I need to output the following to a text file so that we can review it:

get-recipient -OrganizationalUnit "domain.com/users" | get-Logonstatistics | fl username, name, clientname, clientmode

I've tried >> c:\text.txt, and a couple of other things but it's failing.

I'm just trying to find out who is this location is using cached mode and who isn't.

So, how do I output, and why isn't >> working?
###### Who is Participating?

x

Commented:
A correction to my last post

get-mailbox -OrganizationalUnit "domain.com/users" | get-Logonstatistics | select-object username, name, clientname, clientmode | Export-csv c:\file.txt
0

Commented:
you can try export csv with a select object
get-recipient -OrganizationalUnit "domain.com/users" |
get-Logonstatistics |
select-object username, name, clientname, clientmode |
export-csv c:\file.csv

0

Author Commented:
I tried that and got this error:

Get-LogonStatistics : Cannot bind argument to parameter 'Database' because it is null.
0

Commented:
Modern OS systems do not like anything writing to the root of the C: drive.  Did you try sending the file to a subdirectory?
0

Author Commented:
no, but I've never had a problem sending output to the root with powershell in the past.
0

Commented:
Sorry I thought the question was in relation to exporting the data to file.
I hadn't actually analysed the get-logon...
Has that command worked previously?
0

Author Commented:
The command works great until I try to save the output to a file.
0

Commented:
get-recipient -OrganizationalUnit "domain.com/users" | get-Logonstatistics | select-object username, name, clientname, clientmode | Export-csv c:\file.txt
0

PowerShell DeveloperCommented:
This error:

Get-LogonStatistics : Cannot bind argument to parameter 'Database' because it is null.

Is not caused by your attempts to get it to go out to a file. Is that the only error you ever get?

Chris
0

Author Commented:
This last one worked!  Thanks for the help!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.