|
1 | 1 | Add-Type -Path "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.dll" |
2 | 2 | Add-Type -Path "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.Runtime.dll" |
3 | 3 |
|
4 | | -function Set-SPOWebRequestAccessEmail |
5 | | -{ |
6 | | -param ( |
7 | | - [Parameter(Mandatory=$true,Position=1)] |
| 4 | +function Set-SPOWebRequestAccessEmail{ |
| 5 | +param ( |
| 6 | +[Parameter(Mandatory=$true,Position=1)] |
8 | 7 | [string]$Username, |
9 | 8 | [Parameter(Mandatory=$true,Position=2)] |
10 | 9 | [string]$Url, |
11 | | - [Parameter(Mandatory=$true,Position=3)] |
| 10 | +[Parameter(Mandatory=$true,Position=3)] |
12 | 11 | $password, |
13 | 12 | [Parameter(Mandatory=$true,Position=4)] |
14 | 13 | [string]$RequestAccessEmail |
15 | | -) |
16 | | - |
17 | | - |
18 | | - $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) |
19 | | - $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) |
20 | | - $ctx.Load($ctx.Web) |
21 | | - $ctx.ExecuteQuery() |
22 | | - Write-Host "Changing for " $ctx.Web.Url |
23 | | - $ctx.Web.RequestAccessEmail=$RequestAccessEmail |
24 | | - $ctx.Web.Update() |
25 | | - $ctx.ExecuteQuery() |
26 | | - |
27 | | - $ctx.Load($ctx.Web.Webs) |
28 | | - $ctx.ExecuteQuery() |
29 | | - |
30 | | - if($ctx.Web.Webs.Count -ne 0) |
31 | | - { |
32 | | - foreach($webbie in $ctx.Web.Webs) |
33 | | - { |
34 | | - |
35 | | - |
36 | | - Set-SPOWebRequestAccessEmail -Username $Username -Url $webbie.Url -password $password -RequestAccessEmail $RequestAccessEmail |
37 | | - |
38 | | - |
39 | | - } |
40 | | - |
41 | | - } |
42 | | - |
43 | | - } |
| 14 | +) |
| 15 | + |
| 16 | + |
| 17 | +$ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) |
| 18 | +$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) |
| 19 | +$ctx.Load($ctx.Web) |
| 20 | +$ctx.ExecuteQuery() |
| 21 | +Write-Host "Changing for " $ctx.Web.Url |
| 22 | +$ctx.Web.RequestAccessEmail=$RequestAccessEmail |
| 23 | +$ctx.Web.Update() |
| 24 | +$ctx.ExecuteQuery() |
| 25 | + |
| 26 | +$ctx.Load($ctx.Web.Webs) |
| 27 | +$ctx.ExecuteQuery() |
| 28 | + |
| 29 | +if($ctx.Web.Webs.Count -ne 0){ |
| 30 | +foreach($webbie in $ctx.Web.Webs){ |
| 31 | +Set-SPOWebRequestAccessEmail -Username $Username -Url $webbie.Url -password $password -RequestAccessEmail $RequestAccessEmail |
| 32 | +} |
| 33 | +} |
| 34 | +} |
44 | 35 |
|
45 | 36 |
|
46 | 37 | # Paths to SDK. Please verify location on your computer. |
|
0 commit comments