Solved

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

Posted on 2013-12-10
6
1,758 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
Do email signature updates give you a headache?

Do you feel like you are constantly making changes to email signatures? Are the images not formatting how you want them to? Want high-quality HTML signatures on all devices, including on mobiles and Macs? Then, let Exclaimer solve all your email signature problems today.

 

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

Why are Office 365 signatures so complicated?

Trying to setup transport rules for Office 365 email signatures and can’t quite figure it out? Having to test the signature over and over? Make things simple by using Exclaimer Cloud - Signatures for Office 365.

Question has a verified solution.

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

In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
Find out what you should include to make the best professional email signature for your organization.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
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…

910 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

22 Experts available now in Live!

Get 1:1 Help Now