?
Solved

Need help with PowerShell command

Posted on 2014-01-20
2
Medium Priority
?
320 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 900 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

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

Unified and professional email signatures help maintain a consistent company brand image to the outside world. This article shows how to create an email signature in Exchange Server 2010 using a transport rule and how to overcome native limitations …
Check out this step-by-step guide for using the newly updated Experts Exchange mobile app—released on May 30.
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…
Suggested Courses

765 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