Solved

Need help with PowerShell command

Posted on 2014-01-20
2
311 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
Comment Utility
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
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Utilizing an array to gracefully append to a list of EmailAddresses
Exchange server is not supported in any cloud-hosted platform (other than Azure with Azure Premium Storage).
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

772 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

15 Experts available now in Live!

Get 1:1 Help Now