Advertisement

Responsive Advertisement

Add/uploads an available app to the SharePoint Online O365 using PNP Powershell

The Office 365 Developer Patterns and Practices PowerShell Cmdlets turn out to be lifesavers for many Developers. This will  allow you to create artifacts in your SharePoint sites, like lists, fields, etc. without needing to click around or write a complex C# application.

The PowerShell Cmdlets come in 2 versions:
  • Office 365
  • On-prem
To run these scripts, you need to install the SharePoint Online Management Shell and PnP PowerShell modules if you have not yet done so.
For PowerShell 5.0 or newer, run this command
Install-Module Microsoft.Online.SharePoint.PowerShell

For older versions, download and run the SharePoint Online Management Shell installation package. After that, run this command in PowerShell as administrator: 

Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking

To install PnP PowerShell, run this command as administrator:
Install-Module SharePointPnPPowerShellOnline -AllowClobber
It’s good to update both of the modules regularly to get the latest changes and possible new command-lets.
If you want to run the scripts by executing .ps1 files, you also need to run this command as administrator: 

Set-ExecutionPolicy Unrestricted

And a quick note in case you are using multi factor authentication (MFA): you need to change the authentication in the scripts slightly.
  • In the Connect-SPOService command-let, remove the -Credential parameter and its value. Doing so brings up the web login instead, which will prompt you for the authentication code.
  • For Connect-PnPOnline, omit the -Credentials parameter and its value, and replace it with -UseWebLogin.
This below app will help you to understand how to add/uploads an available app to the app catalog using PNP Powershell cmdlets

Add-PnPApp -Path ./myHelloWorldAPP.sppkg

If you want to upload the specified app package to the site collection app catalog and deploy/trust it at the same time.

Add-PnPApp -Path ./myapp.sppkg -Scope Site -Publish


Post a Comment

0 Comments