File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed
Tenant Settings/Prevent external users from resharing Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ function Set-SiteColl
2+ {
3+ param (
4+ [Parameter (Mandatory = $true , Position = 1 )]
5+ [string ]$Username ,
6+ [Parameter (Mandatory = $true , Position = 2 )]
7+ [string ]$Url ,
8+ [Parameter (Mandatory = $true , Position = 3 )]
9+ $password ,
10+ [Parameter (Mandatory = $true , Position = 4 )]
11+ $PreventExternalUsersFromResharing
12+ )
13+
14+
15+ $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($url )
16+ $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username , $password )
17+ $ctx.Load ($ctx.Web )
18+ $ctx.ExecuteQuery ()
19+
20+ $spoTenant = New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant($Ctx )
21+ $ctx.Load ($spoTenant )
22+ $ctx.ExecuteQuery ()
23+ $spoTenant.PreventExternalUsersFromResharing = $PreventExternalUsersFromResharing
24+ $ctx.Load ($spoTenant )
25+ $ctx.ExecuteQuery ()
26+ Write-Output $spoTenant
27+
28+ }
29+
30+
31+
32+
33+ # Paths to SDK
34+ Add-Type - Path " C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
35+ Add-Type - Path " C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.Online.SharePoint.Client.Tenant.dll"
36+
37+
38+
39+ # Enter the data
40+ $AdminPassword = Read-Host - Prompt " Enter password" - AsSecureString
41+ $username = " admin@TENANT.onmicrosoft.com"
42+ $Url = " https://TENANT-admin.sharepoint.com"
43+ $PreventExternalUsersFromResharing = $true
44+
45+
46+
47+
48+
49+ Set-SiteColl - Username $username - Url $Url - password $AdminPassword - PreventExternalUsersFromResharing $PreventExternalUsersFromResharing
You can’t perform that action at this time.
0 commit comments