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?
 
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
Evaluating UTMs? Here's what you need to know!

Evaluating a UTM appliance and vendor can prove to be an overwhelming exercise.  How can you make sure that you're getting the security that your organization needs without breaking the bank? Check out our UTM Buyer's Guide for more information on what you should be looking for!

 
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
All Courses

From novice to tech pro — start learning today.