M365: O365 Groups – PowerShell script to verify whether guest access is enable or disabled

Hi All,

LIFE IS BEAUTIFUL 🙂 Today with O365 groups 🙂

Background: We have O365 applications where users orders Teams. We have custom form for ordering the Teams. On custom form there is classification selection either Internal or External as shown in below figure:

Custom Teams creation App - "External classification" field based on this External sharing will be enabled or disabled
Fig1: M365 : Custom Teams creation App – “External classification” field based on this External sharing will be enabled or disabled

So here, if Team owner has selected classification as “External” then we are enabling guest access on respective O365 group otherwise disabling the guest access.

So we have implementation done and we are testing but any how we noticed that guest access settings are not working. So we need to check whether really guest access which we are updating through our CSOM job is working or now.

To verify guest access is really working for Office 365 group or not, we have only one option PowerShell script. So here is the article, I am sharing this small PowerShell script.

AllowToAddGuests” property is used to update the “Guest Access” for O365 group. This means ability to add guest to O365 group owners.

Detailed Steps:

  • Import “AzureADPreview” module
  • Connect to AzureAD
  • Get the group ID
  • Get the group settings

Complete PowerShell script:

When we will execute the above commands, it will prompt for User Name and Passwords as

M365 : O365 Group - Connecting to Azure AD - Prompt for User Name
Fig2: M365 : O365 Group – Connecting to Azure AD – Prompt for User Name
M365 : O365 Group - Connecting to Azure AD - Prompt for Password
Fig3: M365 : O365 Group – Connecting to Azure AD – Prompt for Password
M365 : Verifying guest access for O365 group and Script
Fig4: M365 : Verifying guest access for O365 group and Script

In separate article I’ll share another PowerShell script – How to enable / disable guest access to the O365 group.

References:

Enjoy the LIFE journey 🙂 Feel free to connect us, Feedback / Suggestions / Comments are welcome 🙂

Advertisements

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.