Moreover Team site evolved in something which is more user friendly, and people are able to create their own site for a project (mixing together Planner, SharePoint Online, OneDrive and other stuff) in order to include also external users and make them able to interact with them: this is common if the customer outsources lots of activities.
Lately i found a curious problem, i created a SharePoint group with also external users, after that i broke inheritance on some document library (customer does not want to allow everyone to see what's happening on the project site) and assign some custom permission to external users.
So i created custom groups and added people, and, even if O365 gave me no error, no user was added. I kept trying without results and, because i've to go on vacancy, i had to solve the problem easily.
At first time i read this link and then this other one by Microsoft and i set up this value as site collection sharing capability one.
Set-SPOSite -Identity https://contoso.sharepoint.com/sites/site1 -SharingCapability ExternalUserSharingOnlyI noticed that, if you face that problem, even if you are not able to accomplish the task using UI, you can do it using PowerShell, so, i created this small script that can help you to save your vacancy.
I have not found the root cause, meantime, have fun with this.
Before reading the other script, i wanna thank you Simone Anzaldi (Big up) who helped me with this problem.
# PARAM $URL = "https://varrocorp.sharepoint.com/sites/Test" $USR = "admin@varrocorp.it" $PWD = "UsernamePassword" $GROUPNAME = "Da Group" $EXTERNALUSERNAME = "user@externaldomain.com" # Import some libraries Import-Module MSOnline Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($URL) # Just converting plain text to secure string $pwd = ConvertTo-SecureString -String $PWD -AsPlainText -Force $creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($USR, $PWD) $ctx.credentials = $creds # Get root site details $web = $ctx.Site.RootWeb # Gets all site groups $groups = $web.SiteGroups $ctx.Load($groups) $ctx.ExecuteQuery() # Get user info of the external user $userInfo = $web.EnsureUser($EXTERNALUSERNAME) $ctx.Load($userInfo) # Get group by name and add the user $group = $web.SiteGroups.GetByName($GROUPNAME) $addUser = $group.Users.AddUser($userInfo) $ctx.Load($addUser) $ctx.ExecuteQuery() # Paranoid check $group = $web.SiteGroups.GetByName($GROUPNAME) $users = $group.Users $ctx.Load($users) $ctx.ExecuteQuery() foreach($user in $users){ Write-Host " " $user.Title }
0 commenti:
Post a Comment
Because of a lot of SPAM about courses, I need to moderate all comments here.
I ensure you that I will answer whenever possible (if you are not a spammer).