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?
ddotsonAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
AkhaterConnect With a Mentor 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
 
gazm81Commented:
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

Open in new window

0
 
ddotsonAuthor Commented:
I tried that and got this error:

Get-LogonStatistics : Cannot bind argument to parameter 'Database' because it is null.
0
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

 
nwtechdeskCommented:
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
 
ddotsonAuthor Commented:
no, but I've never had a problem sending output to the root with powershell in the past.
0
 
gazm81Commented:
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
 
ddotsonAuthor Commented:
The command works great until I try to save the output to a file.
0
 
AkhaterCommented:
get-recipient -OrganizationalUnit "domain.com/users" | get-Logonstatistics | select-object username, name, clientname, clientmode | Export-csv c:\file.txt
0
 
Chris DentPowerShell 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
 
ddotsonAuthor 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.