forked from pnp/custom-learning-office-365
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UpdateM365lpCDN.ps1
47 lines (40 loc) · 1.39 KB
/
UpdateM365lpCDN.ps1
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
47
param([string]$TenantName)
try {
$NotFound = $true
$oldPreference = $ErrorActionPreference
$ErrorActionPreference = ‘stop’
# verify the PnP cmdlets we need are installed
if (Get-Command Connect-PnPOnline ) {
Write-Host "Found PnP Command"
$NotFound = $false
}
}
catch {
Write-Warning "Could not find PnP PowerShell cmdlets"
Write-Warning "Please install them and run this script again"
Write-Warning "You can install them with the following line:"
Write-Warning "`nInstall-Module PnP.PowerShell`n"
}
finally {
$ErrorActionPreference = $oldPreference
if ($NotFound) { exit }
}
# Check if tenant name was passed in
if ([string]::IsNullOrWhitespace($TenantName)) {
# No TenantName was passed, prompt the user
$TenantName = Read-Host "Please enter your tenant name: (contoso) "
}
$AdminURL = "https://$TenantName.sharepoint.com"
# Connect to Admin site.
# Todo: Differentiate between valid $adminurl and authentication error (bad password or no access)
try {
Connect-PnPOnline -Url $AdminURL -UseWebLogin
}
catch {
Write-Warning "Failed to authenticate to $AdminURL"
Write-Warning $_
break
}
Set-PnPStorageEntity -Key MicrosoftCustomLearningCdn -Value "https://pnp.github.io/custom-learning-office-365/learningpathways/" -Description "Microsoft 365 learning pathways CDN source" -ErrorAction Stop
Get-PnPStorageEntity -Key MicrosoftCustomLearningCdn
Disconnect-PnPOnline