Solved

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

Posted on 2013-12-10
6
1,733 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
Want to promote your upcoming event?

Is your company attending an event or exhibiting at a trade show soon? Are you speaking at a conference? Spread the word by using a promotional banner in your email signature. This will ensure your organization’s most important contacts are in the know.

 

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
This article explains in simple steps how to renew expiring Exchange Server Internal Transport Certificate.
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…
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager

708 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