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:

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
Import-Module AzureADPreview
- Connect to AzureAD
AzureADPreview\Connect-AzureAD
- Get the group ID
$groupID= (Get-AzureADGroup -SearchString "<Group name>").ObjectId
- Get the group settings
Get-AzureADObjectSetting -TargetObjectId $groupID -TargetType Groups | fl Values
Complete PowerShell script:
Import-Module AzureADPreview
AzureADPreview\Connect-AzureAD
$groupID= (Get-AzureADGroup -SearchString "<Group name>").ObjectId
Get-AzureADObjectSetting -TargetObjectId $groupID -TargetType Groups | fl Values
When we will execute the above commands, it will prompt for User Name and Passwords as



In separate article I’ll share another PowerShell script – How to enable / disable guest access to the O365 group.
References:
- AzureADPreview
- How To Install AzureAD Preview PowerShell Module
- Manage guest access in Office 365 Groups
- Azure Active Directory cmdlets for configuring group settings
- HOW TO COMPLETELY DISABLE EXTERNAL SHARING FOR A SINGLE OFFICE 365 GROUP
Enjoy the LIFE journey 🙂 Feel free to connect us, Feedback / Suggestions / Comments are welcome 🙂
You must log in to post a comment.