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.
1 | Set -SPOSite -Identity https://contoso.sharepoint.com/sites/site1 -SharingCapability ExternalUserSharingOnly |
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | # PARAM $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).