Solved

Need help with PowerShell command

Posted on 2014-01-20
2
315 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
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Lotus Notes – formerly IBM Notes – is an email client application, while IBM Domino (earlier Lotus Domino) is an email server. The client possesses a set of features that are even more advanced as compared to that of Outlook. Likewise, IBM Domino is…
Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

821 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