Solved

# Output Powershell to Text File problem

Posted on 2011-09-09
912 Views
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?
0
Question by:ddotson
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 4
• 2
• 2
• +2

LVL 2

Expert Comment

ID: 36514417
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 Comment

ID: 36514425
I tried that and got this error:

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

LVL 8

Expert Comment

ID: 36514528
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 Comment

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

LVL 2

Expert Comment

ID: 36514619
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 Comment

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

LVL 49

Expert Comment

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

LVL 71

Expert Comment

ID: 36518648
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

LVL 49

Accepted Solution

Akhater earned 250 total points
ID: 36518713
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

Author Comment

ID: 36523833
This last one worked!  Thanks for the help!
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
In this video we show how to create a Shared Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Recipients >> Sha…
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager
###### Suggested Courses
Course of the Month1 day, 17 hours left to enroll