Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Exchange Management Shell

Posted on 2015-01-16
1
Medium Priority
?
213 Views
Last Modified: 2015-01-16
I'm trying to export a list of mailboxes that a particular user has full manage access to. I'm trying to export this information to a csv file. The csv file is created but there is not information in the file.  If I run the cmd without the export-csv c:\name.csv then the information is populated to the screen of the shell, which is fine but I need this info in the csv. See below for the script I run. Any help would be great.

$mailboxes = Get-Mailbox -ResultSize Unlimited
foreach ($mailbox in $mailboxes){
Get-MailboxPermission -Identity $mailbox.Alias -User "username" | fl identity, AccessRights
}

The above script populates the shell screen just fine,  but if I run the following:
$mailboxes = Get-Mailbox -ResultSize Unlimited
foreach ($mailbox in $mailboxes){
Get-MailboxPermission -Identity $mailbox.Alias -User "username" | fl identity, AccessRights | export-csv c:\name.csv
}

Or if I change it to :
$mailboxes = Get-Mailbox -ResultSize Unlimited
foreach ($mailbox in $mailboxes){
Get-MailboxPermission -Identity $mailbox.Alias -User "username" | select identity, AccessRights | export-csv c:\name.csv
}
On the above I tried select and select-object and neither populates the csv file even though it creates it. Any idea how I can make this work and thanks in advance.
0
Comment
Question by:timgreen7077
[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
1 Comment
 
LVL 67

Accepted Solution

by:
sirbounty earned 2000 total points
ID: 40554739
You should exclude the format-list, and just use export-csv.
Try this:
$mailboxes = Get-Mailbox -ResultSize Unlimited
foreach ($mailbox in $mailboxes){
  $perms += @(Get-MailboxPermission -Identity $mailbox.Alias -User "username")
}
$perms | select identity, accessrights | export-csv c:\name.csv
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
One-stop solution for Exchange Administrators to address all MS Exchange Server issues, which is known by the name of Stellar Exchange Toolkit.
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…
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…

722 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