Deploy sppkgs and install apps
Summary
Deploy all packages from a local folder and install the apps to the SharePoint site.
param (
[Parameter(Mandatory = $true)]
[string]$url,
[Parameter(Mandatory = $true)]
[string]$username,
[Parameter(Mandatory = $true)]
[string]$password
)
clear-host
# Connect
$psw = ConvertTo-SecureString -String $password -AsPlainText -Force
$credentials = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $UserName, $psw
Connect-PnPOnline -Url $url -Credentials $credentials
# Local sppkg folder path
$sppkgFolder = "./packages"
Write-Host ("Deploying packages to {0}..." -f $url) -ForegroundColor Yellow
$packagesFiles = Get-ChildItem $sppkgFolder
foreach ($package in $packagesFiles) {
Write-Host ("Installing {0}..." -f $package.PSChildName) -ForegroundColor Yellow
# Deploy sppkg
$App = Add-PnPApp -Path ("{0}/{1}" -f $sppkgFolder, $package.PSChildName) -Scope Site -Publish -Overwrite
#Install app
if($null -eq $App.InstalledVersion) {
Install-PnPApp -Identity $App.Id -Scope Site
}
}
Disconnect-PnPOnline
Write-Host ("DONE") -ForegroundColor Green
Check out the PnP PowerShell to learn more at: https://aka.ms/pnp/powershell
The way you login into PnP PowerShell has changed please read PnP Management Shell EntraID app is deleted : what should I do ?
Contributors
Author(s) |
---|
Matteo Serpi |
Disclaimer
THESE SAMPLES ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.