-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.ps1
46 lines (38 loc) · 1.37 KB
/
install.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
function log {
param (
$Message
)
Write-Host $Message -ForegroundColor Yellow -BackgroundColor Black
Write-Host " "
}
log "Uploading to SharePoint"
$SiteURL = "https://legodan.sharepoint.com/sites/LegoDanDev"
$FilesPath = "L:\Repos\darklordstudios\dlsvue-sp-script-widget\sharepoint\solution"
$serverRelativePath = "/sites/LegoDanDev/AppCatalog"
$AppName = "DLS VUE Script Loader Web Part"
Connect-PnPOnline -Url $SiteURL -Interactive -Verbose
$PackageFiles = Get-ChildItem -Path $FilesPath -Force -File "dlsvue-sp-script-widget.sppkg"
ForEach ($File in $PackageFiles) {
Write-Host "Uploading $($File.Directory)\$($File.Name)"
Add-PnPFile -Path "$($File.Directory)\$($File.Name)" -Folder $serverRelativePath -Values @{ "Title" = $($File.Name) }
Start-Sleep -Seconds 5
$App = Get-PnPApp -Scope Site | Where-Object { $_.Title -eq $AppName }
Publish-PnPApp -Identity $App.Id -Scope Site
}
Start-Sleep -Seconds 5
Function UpdateAppFromCatalog {
[cmdletbinding()]
Param(
[parameter(Mandatory = $true, ValueFromPipeline = $true)] $web
)
Try {
$web.Title
Connect-PnPOnline -Url $web.Url -Interactive
$App = Get-PnPApp -Scope Site | Where-Object { $_.Title -eq $AppName }
Update-PnPApp -Identity $App.Id -Scope Site
}
Catch {
Write-Host -f Red "ERROR"
}
}
Get-PnPSubWeb -IncludeRootWeb -Recurse | ForEach-Object { UpdateAppFromCatalog $_ }