Solved

Need help with PowerShell command

Posted on 2014-01-20
2
316 Views
Last Modified: 2014-01-21
Been struggling with this for a few hours. I am sure its simple for someone that knows PowerShell. I want to output the results of the command below to a .txt or .csv file.

$Users = import-csv c:\itemployees.csv
ForEach ($User in $Users) {Get-MailboxFolderStatistics -identity $User.users –folderscope ‘DeletedItems’ | select identity,folderpath,itemsinfolder,foldersize }

A simple | out-file c:\itemployees.txt does not work.

I am sure I am missing some brackets or quotes somewhere in the command. The command itself without the |out-file works just file. When I try to output, I get an error.
0
Comment
Question by:shadowtuck
[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
  • Learn & ask questions
2 Comments
 
LVL 4

Accepted Solution

by:
tmx84 earned 300 total points
ID: 39795388
Try..

$Users = import-csv c:\itemployees.csv
ForEach ($User in $Users) {Get-MailboxFolderStatistics -identity $User.users –folderscope ‘DeletedItems’ | select identity,folderpath,itemsinfolder,foldersize | out-file c:\itemployees.txt -append }
0
 
LVL 13

Expert Comment

by:imkottees
ID: 39795948
even this should works.

Import-Csv c:\itemployees.csv | foreach {get-mailboxfolderstatistics -identity ($_.Alias) -folderscope deleteditems} | select identity, Folderpath, itemsinfolder, foldersize | export-csv c:\folderstat.csv

csv file should have a title called "alias"
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Follow this checklist to learn more about the 15 things you should never include in an email signature from personal quotes, animated gifs and out-of-date marketing content.
A list of top three free exchange EDB viewers that helps the user to extract a mailbox from an unmounted .edb file and get a clear preview of all emails & other items with just a single click on mailboxes.
To show how to create a transport rule 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 Mail Flow >> Rules tab.:  To cr…
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

742 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