Solved

Need help with PowerShell command

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
A couple of months ago we ran into an issue that necessitated re-creating our Edge Subscriptions. However, when we attempted to execute the command: New-EdgeSubscription -filename C:\NewEdgeSub_01.xml we received an error indicating that the LDAP se…
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…
This video discusses moving either the default database or any database to a new volume.

717 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