I have a script running in Azure Automation that creates group connected SharePoint-sites.
The basic line of code for creating site is this:
New-PnPSite -Type TeamSite -Title $Title -Alias $Alias -Lcid 1053
This creates a standard Team site with no additional owners or members.
In a following step we add members to the group utilizing exchange module like this example:
Add-UnifiedGroupLinks -Identity $unifiedGroup.Id -LinkType Member -Links $member.Email
The reason why we do this is because in between these two steps we disable the welcome mail and it is of high importance to our organization that no standard welcome mail goes out. Therefore members has to be added post-creation.
While the above lines of code work just fine the problem occurs when permissions seem to take forever to reflect from group to SharePoint. Same thing goes if we add membership with graph.
I have also tried utilizing
SP.Directory.DirectorySession rest API endpoint through PowerShell web request but I'm stuck with a 403 on that one...
In short what we want. Create a group with no welcome mail going out. Add group permissions immediately reflected to SharePoint. Is there a way to make this work?