Showing posts with label Office365. Show all posts
Showing posts with label Office365. Show all posts

2015/08/29

PowerShell/Office 365 - Get an Exchange Online user's distribution groups efficiently

In my previous post I showed how to retrieve the membership of one or multiple groups. In today's post I want to find the Distribution groups a user belongs to.

There are multiple approaches you could be using to gather this information but as an example I'll re-use the same one-liner from my previous article and simply filter with Where-Object to find a particular User.

This is probably the route PowerShell beginners would take and it is working 'Fine' in a small environment but not very efficient, you'll see in the following example.

In this environment, there are a bit more than 1800 Distribution Groups. I want to know which Distribution Group I'm member of.

Retrieving the count of Distribution Groups and an User account in Office 365


2015/08/24

PowerShell/Office 365 - Get the distribution groups membership

I was recently looking at Office365/Exchange Online to retrieve Distribution Group membership. This is pretty simple using something like:
Get-DistributionGroupMember -Identity "Marketing"

Not that prior to perforce the following command you need to be already connected to Office365, see this post.

Retrieving all members of each Distribution Group

Now if I want to retrieve all the Distribution group members, it's bit trickier you'll see. First I started by listing the groups members. My PowerShell instinct made me type Get-DistributionGroup|Get-DistributionGroupMember but it did not work, see below:



As the error message is stating that this Cmdlet does not accept input :-/

By using Get-Help on Get-DistributionGroupMember, we can check the parameters accepting Input:

(Get-Help Get-DistributionGroupMember).parameters.parameter|Select-Object name,parametervalue,pipelineinput


2015/06/28

PowerShell - Using Office 365 REST API to get Calendar Events

A couple of weeks ago I was looking at a way to find the Calendar Events of an Office365 shared mailbox using PowerShell. Unfortunately I was not able to find a way to accomplished this task using the O365 Cmdlets. (Let me know in the comments if you know how...)

Update 2017/04/02: Support for timezone, Updated the function with error handler and some verbose messages. Added examples to retrieve the list of attendees emails

Update 2016/04/19: Function updated to support PageResult parameter

So I turned to the PowerShell Community and posted tweet about it.


Quickly I got an answer from @Mjolinor and @Glenscales who sent me some great stuff by using REST API. Thanks again guys!!

This is the example Glen sent me:
Invoke-RestMethod -Uri "https://outlook.office365.com/api/v1.0/users/sharedmailbox@domain.com/calendarview?startDateTime=$(Get-Date)&endDateTime=$((Get-Date).AddDays(7))" -Credential (Get-Credential) | foreach-object{ $_.Value }

This example shows how to list the calendar events for the next week. This is great and exactly what I needed, plus this run super fast compared to using the PowerShell module.

Of course you will need to have permissions on the specified mailbox.


Even though it show this as a CustomObject, the object type is Microsoft.OutlookServices.Event, see this MSDN page to find all the properties and methods available: https://msdn.microsoft.com/office/office365/APi/complex-types-for-mail-contacts-calendar#EventResource

2014/07/01

PowerShell - Handy function to connect to Office365 services


I just started to play with a Microsoft Office 365 environment (Azure Active Directory, Lync Online and Exchange Online) and I thought I would make it through PowerShell obviously :-)

But when you start your PowerShell console... you need to load modules, connect to each services, enter your credentials...yada yada yada...

With Office 365 you can administer the following services using PowerShell:
  • Azure Active Directory
  • Exchange Online PowerShell
  • SharePoint Online PowerShell
  • Lync Online PowerShell