in Office 365 you get three types of groups: distribution groups, dynamic distribution groups, and Office 365 groups (unified groups)…

The first two of those are based on Exchange Server and are very straight and easy to use for anyone who is familiar with Exchange Server… However the third type might look something new to them despite being at the same level of ease and straight forward!

When using Exchange Online PowerShell to list the groups, there are three commands to use for this:

Get-DistributionGroup
Get-DynamicDistributionGroup
Get-UnifiedGroup

Similar to the first two commands, Get-UnifiedGroup works the same way… You will get the group, then check its members attribute or property to get the other member users…

Below is a small script that I made will do the required job for you. Once the process is completed, you will get a file named O365GroupMembers.csv contains four columns!

$output = @()
$groups 
Read the rest “PS: A small script to list Office 365 groups and members”

A quick and nice script to get all groups and their member users exported in PowerShell… you might need that for multiple reasons, and getting them quick is a nice thing…

Today I needed that for a customer who asked for it because he was cleaning his 1000 users active directory, and lucky me, the force of PowerShell can just do anything!

Script:

$groups = get-adgroup -filter *
foreach ($group in $groups)
{
    echo "Group: $group - Member list:"
    get-adgroupmember -identity "$group" | select Name, SamAccountName | ft -au
}

The above will just display the output on the screen, so in order to have it in a file, you can save the script to a file then pass it to Out-File with your desired file name…

Example:

Get-ADGroupsAndMembers.ps1 | Out-File c:\all_users_and_groups.csv

I have attached the script file (.ps1) into this post so you can quickly download it, have fun… … Read the rest “PS: Get all active directory groups with their member users”

In order to get a list of all (or part) of the mailboxes and view their sizes, simply use the following PS script:

Get-mailbox | Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | ft DisplayName, ItemCount, TotalItemSize, Database -auto | Out-File c:\mbx_sizes.txt

The above command, will get all the mailboxes, and list their sizes and the database they are member or, then output the result to a text file called mbx_sizes.txt…

You can change the sorting to be Ascending, to have the smallest mailbox on top…

Also, you can get the sizes for mailboxes in a specific database by:

Get-mailbox -Database <DATABASE_NAME> | Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | ft DisplayName, ItemCount, TotalItemSize, Database -auto | Out-File c:\mbx_sizes.txt

Replace <DATABASE_NAME> with the actual name of your database.

And of course you can do it for 1 mailbox as well by using:

Get-MailboxStatistics -Identity <USER_ID> | ft DisplayName, ItemCount, TotalItemSize

Sometimes you get a sudden need to forward bulk users’ mail to external destination… in normal days, you would create a mail contact, then forward the selected user’s mail to the new external contact.

Now what if you got a large number of contacts to forward? well, you can either:

  1. Manually create all the required mail contacts, then assign each user to each contact.
  2. OR THE BETTER WAY: Use the magic of PowerShell!

This is a very simple and quick procedure…

First, you will need to create the contacts, which you can find how in the following post: PS: Creating bulk mail contacts

Then with another script, you will forward each user to his corresponding mail contact item:

Import-CSV "C:\ContactForward.csv" | Foreach{Set-Mailbox -Identity $_.LocalUser -ForwardingAddress $_.ForwardAddress -DeliverToMailboxAndForward $true}

You can either keep the attribute “-DeliverToMailboxAndForward $true” to keep a copy of the message in the original mailbox or remove it.Read the rest “PS: Bulk forwarding mailboxes to external addresses”

Below is a useful script to create bulk contacts in Exchange Management Shell:

Import-CSV "C:\NameList.csv" | Foreach{New-MailContact -Name $_.Name -ExternalEmailAddress $_.ExternalAddress}

You need to have the following prepared before you use the script:

  1. A CSV file contains 2 headers: Name, ExternalAddress, with all the contacts list that you want to create.
  2. Save the CSV file in C:\ (to be completely complied with the script above, otherwise save it where you want, but make sure you specify it’s full path in the script above instead of “C:\NameList.csv”.

To make it a bit easier, here is the script ready, just open EMS and run it from there after you make sure the file is ready…

Bulk-MailContact

Hello everybody

Last few days  I was having too much troubles with the rain, and the situation was not good at all in Jeddah, I even had to spend 1 night out of home… 🙁 because the water has blocked almost all the roads in the city… actually you can see a bit of what happened from my Facebook profile: http://www.facebook.com/salehram, well, it is in Arabic so you better know some Arabic if you are not Arabic 😛

OK, I almost forgot the main reason of this topic 😀 , it is about managing the Exchange users using the Groups in Active Directory…

There are many ways to manage the users in the Exchange, the easiest at all is using the EMC (Exchange Management Console), and there are many methods to do that, for example you can:

  • Just go for the user you want and right click him
  • Multi-select a
Read the rest “PS: Managing Exchange Users Using Groups”