This article is about how I was able to use the SharePoint Modules to successfully deploy an application to SharePoint Online.
First I needed to start with downloading the latest copy of SharePointPnPPowerShellOnline.
I discovered while using this module that there is the capability to add a PSDrive to my session. This means I should be able to upload files to sharepoint as if it were a drive on my local machine. Here is how you connect to sharpeoint online:
PS> Install-Module -Name SharePointPnPPowerShellOnline $adminpassword = 'password' $adminUserName = 'firstname.lastname@example.org' $creds = $AdminPassword | ConvertTo-SecureString -AsPlainText -Force $SPdevcredentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $AdminUserName, $creds connect-pnponline -Url $url -Credentials $SPdevcredentials -CreateDrive
Now that I have a connection to the SharePoint online instance I can see that I have a new powershell drive through the get-psdrive cmdlet:
As you can see I have a new drive that is configured for use in my session, directorying the SPO: drive will get the contents of the SharePoint Site:
My Applications are in my AppCatalog folder to get to that folder all I need to do is issue a CD to that directory. To upload my App to this folder all I need to do is add it with Add-pnpFile.
I seemed to have the best success when I used Get-Item (gi) and then used the fullname property for the file that I was sending to SharePoint. In addition one other gotcha was that the folder to upload to is a subfolder of the site you are connected to. In my case \sites\apps was my site I was connected to so specifying appcatalog was all I needed.
Now all that I needed to do was to put this in a script that I could call from my CI automation and put some Error logic. Now I have a full fledged script called deployspapp.ps1. Full Source is found on my Gist:
I hope this helped someone
Until then keep scripting