Solved

Output Powershell to Text File problem

Posted on 2011-09-09
10
902 Views
Last Modified: 2012-05-12
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
Comment
Question by:ddotson
  • 4
  • 2
  • 2
  • +2
10 Comments
 
LVL 2

Expert Comment

by:gazm81
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

Open in new window

0
 

Author Comment

by:ddotson
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

by:nwtechdesk
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

by:ddotson
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

by:gazm81
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
Do email signature updates give you a headache?

Are you constantly making changes to email signatures? Are the images not formatting how you want them to? Want high-quality HTML signatures on all devices, including on mobiles and Macs? Then, let Exclaimer solve all your email signature problems today.

 

Author Comment

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

Expert Comment

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

Expert Comment

by:Chris Dent
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

by:
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

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

A procedure for exporting installed hotfix details of remote computers using powershell
Find out what you should include to make the best professional email signature for your organization.
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
how to add IIS SMTP to handle application/Scanner relays into office 365.

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now