Exchange Shell – All Permissions on all Mailboxes

Exchange-Export-all-permissions-on-all-mailboxes

We carried out a project recently which was to migrate around 150 mailboxes to the Office 365 (Exchange Online) platform.

Part of scope of works that was required was to provide the team leaders within the business a list of all the mailboxes and what permissions they had on them.

This was mostly a housekeeping exercise due to years of neglect in that area. As an example, one users mailbox had permissions on it for a colleague to be able to access their inbox whilst they were on annual leave – but was still set on it two and a half years later!

So we turned to Exchange Shell again…

The gift that just keeps giving, PowerShell, or for Exchange, Exchange Shell, was the perfect tool for this job. One simple command and we could output all this information to a CSV file.

Get-Mailbox | Get-MailboxPermission | Select {$_.AccessRights}, Deny, InheritanceType, User, Identity, IsInherited, IsValid | Export-Csv c:\TGH\mbx_permissions.csv

You can amend the above command if you wish to bring in, or remove, any columns of data.

We would then take this CSV file, turn it into a XLSX file and send it to the people that wanted it. If we really wanted to, we could put this into a PowerBI report and create pretty graphs etc – but for this job, an Excel file would do!

The people requesting this information were delighted and a bit shocked that it only took a few minutes to provide to them – but that’s the value of PowerShell.

Feedback

If you run into any problems with this, or if you would like some assist expanding the data column information, please feel free to leave us a message below in our comments section and we will get back to you as soon as we can.

Get folders and sizes for all mailboxes using Exchange Shell

Get folders and sizes for all mailboxes using Exchange Shell

We recently had a request to provide to our Project Management team, a full list of all Exchange mailboxes with all folders within each mailbox and also the total sizes of each folder for each mailbox.

This came as a bit of a shock to us and we still have no idea why they wanted it, but, us techies just get told to do what is needed and not ask questions!

Our first thought was to get some of the Project Management team analysts setup with a basic administrator account on our Exchange and get them to go through it manually. Then we thought that was a bit cruel given that there was over 3500 mailboxes that needed this work carrying out on. Then on the other hand, we did not want to sit there going through all the mailboxes either!

So, then we turned to PowerShell

Once again, the saviour of all techies that do not want to do unnecessary work – PowerShell!

Of course there is a PowerShell script that you can use to carry out this task – there is a PowerShell script for everything, the hard part is finding the correct script for what the data that you want to get.

So between three of us that know PowerShell on an OK basis, we started to put together a basic script that would get the mailboxes, get the statistics, select the data we needed and then show it to us.

PowerShell Script

Below is the PowerShell that we managed to put together to get us the information that we had been asked to provide:

Get-Mailbox | Select-Object alias | foreach-object {Get-MailboxFolderStatistics -Identity $_.alias | select-object Identity, ItemsInFolder, FolderSize}

It seemed to have worked, but all we had was a (very long) page of data. so, we obviously needed to provide it to our Project Management team in a nice pretty Excel spreadsheet.

Export to CSV

This is where we now needed to take the data we had and export it into CSV. Anyone that has used PowerShell will already know this, but just in case, you need to add the pipe export-csv part to the end of the script. So, from using our above script, we would use this:

Get-Mailbox | Select-Object alias | foreach-object {Get-MailboxFolderStatistics -Identity $_.alias | select-object Identity, ItemsInFolder, FolderSize} | export-CSV "C:\mailboxdata.csv"

We then took this CSV file, saved it as a XLSX file format, formatted the data a bit in Excel and created some pointless graphs (PM’s love graphs) and sent it off to our Project Management team.

They were stunned that we had managed to get such a large amount of data to them within the same morning and even questioned whether it was correct or “rushed”. Imagine that, Project Managers questioning the IT Department – whatever next! (sarcasm is meant there…).

So, they were happy, we were happy, everyone was happy. Hopefully you will be too if you can reuse this PowerShell script to impress your PMs or bosses!

Feedback

We would love to hear your feedback on this article so come and join us on Facebook or Twitter and let us know what you think!

Exchange Shell – Get all Shared Mailboxes Information

Exchange 2013

Following on from our previous post about how IT professionals can use the tools available to them to make their lives easier, we have another Exchange Management Shell (EMS) script which will get all the information available from all Shared Mailboxes including the sizes of each mailbox.

Guide

Open up the Exchange Management Script tool and enter this command:

Get-mailbox -RecipientTypeDetails sharedmailbox -Resultsize unlimited | ft Name, Identity, ItemsInFolder, FolderSize

This will return all the information on your businesses shared mailboxes. However, this is only on screen using the EMS and the formatting is not the best.

Export to CSV

The better option is to take all the data and export it to CSV. You can then save the CSV as an XLSX file and carry out any formatting and tidying up that may be required.

So, go back into your EMS and run this command:

Get-mailbox -RecipientTypeDetails sharedmailbox -Resultsize unlimited | ft Name, Identity, ItemsInFolder, FolderSize | Export-CSV C:sharedmailboxinfo.csv

where:

  • C:sharedmailboxinfo.csv = CSV export location and file name

You should now find that you have a CSV file with all the information you require in it.

What more can make my life easier?

Well, we have a number of Powershell scripts available here which might help you out. Otherwise, just that a browse around our site and see what you can find. In the top right is a search function too.

Feedback

If you have any questions or feedback on this guide, please feel free to leave us a message below in our comments section and we will try and get back to you as soon as we can.

Exchange Shell – Export all shared mailbox permissions to CSV

Exchange 2013 1

Sometimes as IT professionals, we get asked to supply a lot of data to company bosses. This can be extremely frustrating especially when what you want to do is fix stuff, but IT is becoming more and more like an admin role all the time. It doesn’t mean you stop fixing stuff, it just means you have to carry out an admin role as well!

So, to try and make our lives easy, we need to use the tools available to us as well as our technical skills.

Our blog is absolutely packed full of user guides for a whole range of different technical areas, but over the next few weeks, our posts are going to largely evolve around PowerShell scripts and how we can use them to make our lives easier.

Microsoft Exchange

Although email is rapidly moving aware from on premise Microsoft Exchange servers and into the cloud, there are still a hell of a lot of business still using older versions of Exchange. In this scenerio, a project manager has asked to be supplied with all Exchange shared mailboxes and who has what permissions to each one.

To carry this out, we can use the Exchange Management Shell (EMS) to input a basic script which will output this information to CSV which then in turn can be passed on to the project manager.

EMS Script

Enter the below script into EMS and this will export the results into a .csv file:

Get-Mailbox -RecipientTypeDetails SharedMailbox | Get-MailboxPermission | Select Identity,User,@{Name=’Access Rights’;Expression={[string]::join(‘, ‘, $_.AccessRights)}} | Export-Csv C:sharedmailboxpermission.csv –NoTypeInformation

where:

  • C:sharedmailboxpermission.csv = CSV save location and file name (don’t actually save to the root of your C: drive – that is stupid and usually throws a permissions error!)

Once the script has completed going through the Exchange databases, it will out the CSV to the location that you specified in the script.

What more can make my life easier?

Well, we have a number of Powershell scripts available here which might help you out. Otherwise, just that a browse around our site and see what you can find. In the top right is a search function too.

Feedback

If you have any questions or feedback on this guide, please feel free to leave us a message below in our comments section and we will try and get back to you as soon as we can.

Exchange Shell – Get all shared mailboxes with primary SMTP

Exchange 2013 1

We recently received a request to provide a project manager with a full list of all shared mailboxes with their primary SMTP addresses that were in Microsoft Exchange.

To do this is a pretty straight forward task using Exchange Management Shell (EMS).

Just go ahead and open your EMS and run the following command:

Get-Mailbox -RecipientTypeDetails SharedMailbox -ResultSize:Unlimited | Select Identity,Alias,DisplayName,primarysmtpaddress | sort displayname

This will go through your Exchange environment and give you a list of all shared mailboxes, their name and the primary SMTP address for each Shared Mailbox.

If you want to export this information to CSV, use the command below:

Get-Mailbox -RecipientTypeDetails SharedMailbox -ResultSize:Unlimited | Select Identity,Alias,DisplayName,primarysmtpaddress | sort displayname | export-CSV C:\TGH\sharedmailboxes.csv

where:

  • C:\TGH\sharedmailboxes.csv = the filepath where you want to save your CSV file

This will then export all the information into a CSV file where you specified in your command line.

Feedback

If you have any questions or feedback on this guide, please feel free to leave us a message below in our comments section and we will get back to you as soon as we can.

Send-As Exchange Universal Distribution Group

Exchange 2013

INTRODUCTION

If you want to allow a user to ‘Send-as’ a Universal Distribution Group, you cannot do this by right clicking the Distribution Group in Exchange and managing send-as permissions as you would with a shared mailbox or user mailbox.

GUIDE

However, the following will allow you to carry this task using Active Directory instead of from within Exchange:

  • Open Active Directory Users & Computers
  • Activate Advanced Features in the View menu
  • Find the distribution list you want to send as
  • Open the properties and go to the Security tab
  • Add the user or group in question
  • Check the Send As permission
  • Apply/OK

This should now give the end user permissions to send as a Distribution Group.

COMMENTS

If you have any questions or feedback on this guide, please feel free to leave us a message below.

Exchange – Hide Contacts from Address Book

5d05eb33135798a962e3199db1fa4a4c

If you have mail contacts in your Exchange environment then you may want to hide them from your global address book if you are using them as forwarders.

To do this, open up Exchange Management Shell (EMS) and run the following command:

Get-MailContact -OrganizationalUnit "ADOU" | Set-MailContact -hiddenfromaddresslistsenabled $true

where:

  • “ADOU” = Organisational Unit
  • $true = set all contacts to hidden (change to $false to un-hide)

This will set all the mail contacts within the stated Active Directory Organisation Unit to hidden and will not show in your global address book.

COMMENTS

If you have any questions or feedback on this guide, please leave us a message below.

Exchange 2007 – Create Multiple Mailboxes using Powershell

Exchange 2013 1

We were recently setting up a test lab with an old version of Exchange 2007 to replicate a customers environment and we had created the required 250 users in Active Directory using some scripts but we also had to then create the mailboxes for these accounts.

Not wanting to sit there manually creating all these mailboxes, we used a quick Powershell command that had it done in 30 seconds.

All you need to do is to run the following command in your Exchange Management Shell:

Get-User -OrganizationalUnit “LAB/Users” | Where-Object{$_.RecipientType -eq “User”} | Enable-Mailbox -Database “LABMBX\MBX1”

where:

  • “LAB/Users” – The OU you want to enable the mailboxes on
  • “LABMBX\MBX1” – your Exchange database where you want to create the mailboxes on

You can also add further parts to your command to scale down the search for users based on Company or Department etc. To this, just add it to the “Where-Object” part – so an example:

Get-User -OrganizationalUnit “LAB/Users” | Where-Object{$_.RecipientType -eq “User” -and $_.department –eq “Sales” -and $_.company -eq “Lab Company”} | Enable-Mailbox -Database “LABMBX\MBX1”

Just change the Sales and Lab Company to whatever you require.

Once you have run this command you should check in your Exchange Management Console and you should then see all the mailboxes that have been created for you.

Feedback

If you have any feedback or queries on this guide, please leave us a message below and we will get back to you when we can.

Exchange – Get Dynamic Distribution Group Individual Members Email Addresses

5d05eb33135798a962e3199db1fa4a4c

If you are using Exchange in our organisation and have dynamic distribution groups, you may want to get all the information about the individual users within these distribution groups and also list their email addresses.

To do this, open up an Exchange Management Shell console and run the following script:

$group = Get-DynamicDistributionGroup –identity “yourDL”
Get-Recipient –RecipientPreviewFilter $group.RecipientFilter | select name,primarysmtpaddress | Export-CSV C:yourdl.csv

Where:

  • “yourDL” = The name of the dynamic distribution group that you want to get the information for
  • C:yourdl.csv = the location where you want to export the CSV file to

This will now export to CSV the name and primary SMTP address of each member of this distribution group.

COMMENTS

If you have any questions or feedback on this guide, please feel free to leave us a comment below using our comments system.

Exchange – Export Contacts to PST using Powershell

Exchange 2013 1

If you want to export a users set of contacts from Exchange directly into a PST file using Powershell, then you can run this command using Exchange Management Shell (EMS):

export-mailbox -id User1 -includefolders 'contacts' -pstfolderpath C:User1.pst

Where:

  • User1 = the mailbox that you want to export from
  • C:User1.pst = the PST filename where you want to export to

COMMENTS

If you have any questions or feedback on this guide, please feel free to leave us a message below using our comments system.

 

Exchange – Disable & Enable Mailbox Features based on Organisation Unit

5d05eb33135798a962e3199db1fa4a4c

In Exchange you can have a number of mailbox features either enabled or disabled for each mailbox. These features include Outlook Web Access (OWA), POP3, IMAP and ActiveSync.

If you want to enable or disable all or any of these features on bulk or by Organisational Unit (OU) then you can use the following Exchange Management Shell PowerShell script to carry this out – just amend the script as you require it:

$OU='OU=IT,OU=Blog,DC=techygeekshome,DC=info'
Get-CASMailbox -OrganizationalUnit $OU | Set-CASMailbox -OWAEnabled:$false -ActiveSyncEnabled:$false -PopEnabled:$false -MAPIEnabled:$false -IMAPEnabled:$false

WHERE:

  • $OU = The variable for the OU that you want to run this script on
  • -OWAEnabled:$false
  • -ActiveSyncEnabled:$false
  • -PopEnabled:$false
  • -MAPIEnabled:$false
  • -IMAPEnabled:$false

The above will disable the features, if you want to enable the features, simply change $false to $true

Then hit enter an run the script and it will change all the selected features on all mailboxes within the selected OU. You can also just select the features you want to enable or disable – you do not have to state all of the above.

COMMENTS

If you have any questions or comments on this guide, please feel free to leave us a message below using our comments system.