Skip to content

Commit 2dd8dfa

Browse files
authored
Update RequestEmailAddress.ps1
1 parent 00628c8 commit 2dd8dfa

File tree

1 file changed

+25
-34
lines changed

1 file changed

+25
-34
lines changed

Site Management/Set RequestAccessEmail for all subsites in one site collection/RequestEmailAddress.ps1

Lines changed: 25 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,37 @@
11
Add-Type -Path "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.dll"
22
Add-Type -Path "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.Runtime.dll"
33

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)]
87
[string]$Username,
98
[Parameter(Mandatory=$true,Position=2)]
109
[string]$Url,
11-
[Parameter(Mandatory=$true,Position=3)]
10+
[Parameter(Mandatory=$true,Position=3)]
1211
$password,
1312
[Parameter(Mandatory=$true,Position=4)]
1413
[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+
}
4435

4536

4637
# Paths to SDK. Please verify location on your computer.

0 commit comments

Comments
 (0)