Solved

Powershell script for list of all users, city, state, and mailbox size

Posted on 2013-12-10
6
1,835 Views
Last Modified: 2014-01-15
I need one command to run the a list in Excel for all users, city, state, and mailbox size. I can run this from 2 commands but want to know if there is one single powershell cmd that can accomplish this.
0
Comment
Question by:CiscoAzn
  • 3
  • 3
6 Comments
 
LVL 53

Expert Comment

by:Will Szymkowski
ID: 39708990
You are trying to pull data from 2 different modules activedirectory and Exchange. You can merge the commands together and use the "out-file" command with -append switch to append the results to the same file, but the commands need to be run separate and the results would not be in the respective columns beside them it would be appended at the bottom.

Will.
0
 

Author Comment

by:CiscoAzn
ID: 39709069
How would you merge the cmds together? Is there a way to script this all to a .ps1 file?
0
 
LVL 53

Expert Comment

by:Will Szymkowski
ID: 39709141
Use the following Powershell script below...
Import-module activedirectory
Add-PSSnapin Microsoft.Exchange.Management.Powershell.Admin
Get-ADUser -Filter * -Properties * | Select DisplayName, City, State | Out-File "c:\export.csv" -append
Get-Mailbox -ResultSize "Unlimited" | Get-mailboxStatistics | Select DisplayName, TotalItemSize, TotalDeletedItemSize | Out-File "c:\export-csv" -append

Open in new window

The code above will run each command seprately and it will append the results to the same CSV file.

You need to have Powershell and both Active Directory and Exchange modules/Snapins added to the session in order for this to work. Depeneding on the version of Exchange you are running you might have to change the ADD-PSSnapin line accordingly.

Will.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:CiscoAzn
ID: 39709466
Script didn't work.
0
 
LVL 53

Accepted Solution

by:
Will Szymkowski earned 500 total points
ID: 39709483
Did it provide any errors where it failed? The module/snapins have to be correct for it to work. Try running each command 1-4 separately in a powershell session and see where it fails. Provide the failure message so we figure out where the script is failing...

Will.
0
 

Author Closing Comment

by:CiscoAzn
ID: 39782330
I apologize for not getting back on this and thank you for your assistance.
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

This article describes my battle tested process for setting up delegation. I use this process anywhere that I need to setup delegation. In the article I will show how it applies to Active Directory
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
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…
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…

726 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