Hello,
Here we are going to connect SharePoint Online using PnP PowerShell and SharePoint Online Management Shell from your machine. If you have an issue while accessing PnP from your Windows 7 or 8 please refer this article – How to use PnP PowerShell in Windows 7 or Windows 8 machine
Here we are have two different approach to connect SharePoint Online site using PowerShell.
1. PnP PowerShell (useful for provisioning of site, adding content type, columns, lists etc)
2. SharePoint Online Management Shell (useful for handling functionality in admin side like services, delete site etc)
Connecting to SharePoint Online using PnP PowerShell:
Open the PowerShell as an Administrator and run the below command, because we need to have PowerShell Gallery in your machine.
Install-Module -Name SharePointPnPPowerShellOnline
Once the PowerShell Gallery is installed, you can connect to your SharePoint online site and check whether can access SharePoint online site from your system.
Connect-PnPOnline -Url https://yoursite.sharepoint.com/sites/mysite
You will get a prompt and it asks for the credentials (If you don’t want this prompt then you can add your site, username and password in “Credential Manager” (Start -> Credential Manager) and click on “Add Generic Credential“.
Now you will be connected to this site as far as this PowerShell window is alive and if you want to disconnect then you use the command. You can check by running
Get-PnPList and you will receive all the lists available in the site
Disconnect-PnPOnline
There are various PnP command commands available in Microsoft site and you can utilize those as per your need. We can use this main for Provisioning of site with predefined template. In the below link you can find PnP commands.
https://docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/add-pnpapp?view=sharepoint-ps
Connecting to SharePoint Online using SharePoint Online Management Shell:
Here we need to install a package called SharePoint Online Management Shell and it is available in the below link, and this is useful when you want to do something in Admin level where you would like to connect to service, delete site etc.
https://www.microsoft.com/en-us/download/details.aspx?id=35588
Install the downloaded Windows Installer in your machine. Open the Windows PowerShell and enter the below script to connect to SharePoint Online service, the URL should needs to be admin SharePoint URL
Connect-SPOService -Url https://yoursite-admin.sharepoint.com/
Now you will be connected to this site as far as this PowerShell window is alive and if you want to disconnect then you use the command. You can check by running.
Happy Coding
Ahamed
Leave a comment