Yes/No Column PnP PowerShell

PnP PowerShell comes in handy when performing various operations in SharePoint Online. You can use this to provision the site, manage the site columns, manage the content types, and a variety of other things. To perform any of the PnP PowerShell-supported operations in SharePoint Online, the first step is to connect to SharePoint Online and set up the context. In this article, we will go over the various approaches to establishing a connection as well as the steps required to do so.


Before we begin, ensure that you have already installed the PnP PowerShell module. If you need assistance installing the PnP PowerShell, please see this article:

Various approaches to Connect SharePoint Online

The PnP PowerShell module offers several ways to connect to SharePoint Online. We’ll go over a few of them here.

Connect using the credentials (username and password)

Run the below mentioned command in Windows PowerShell:

# Url of the SharePoint Online Site Collection
# Replace this with your site collection url that needs to be connected 
$SiteUrl = "" 

# Connect to the SharePoint Online Site Collection
Connect-PnPOnline -Url $SiteUrl
PnP PowerShell Command to establish connection using Credentials

When you run these commands, a pop-up screen will appear, as shown below, asking for the hard-coded credentials:

Window to capture the username and password

Enter the username and password in the window and click OK to connect to the SharePoint Online.

Connect using the Interactive Method

When multi-factor authentication is enabled and you want to connect to SharePoint Online using your username and password, use this method. To use this method, follow the steps outlined below:

# Url of the SharePoint Online Site Collection 
$SiteUrl = "" 

# Connect to the SharePoint Online Site Collection
Connect-PnPOnline -Url $SiteUrl -Interactive

After completing these steps, a new window (as shown in the screenshot below) will appear on the screen for multi-factor authentication:

Interactive method for Multi Factor Authentication

To connect to the SharePoint Online Site Collection, enter the username and password and authenticate using multi factor authentication.

Connect using the SharePoint App (Client ID & Client Secret)

To use this method, we must first register a SharePoint App in the site collection and grant it at least read permission. Once you have granted the permissions, use the following code to connect to SharePoint Online:

Tip: If you need any assistance in setting up the SharePoint App, please visit this post:

# Url of the SharePoint Online Site Collection 
$SiteUrl = ""
$ClientId = "<Replace it with the Client ID of SharePoint App>"
$ClientSecret = "<Replace it with the Client Secret of SharePoint App>"

# Connect to the SharePoint Online Site Collection
Connect-PnPOnline -Url $SiteUrl -ClientId $ClientId -ClientSecret $ClientSecret

Please note that this is a legacy authentication approach so when we use this approach, pnp PowerShell shows a warning as shown below:

WARNING: Connecting with Client Secret uses legacy authentication and provides limited functionality. We can for instance not execute requests towards the Microsoft
Graph, which limits cmdlets related to Microsoft Teams, Microsoft Planner, Microsoft Flow and Microsoft 365 Groups. You can hide this warning by using Connect-PnPO
nline [your parameters] -WarningAction Ignore

Official Documentation

There are a few more approaches supported by PnP PowerShell for connecting to SharePoint Online. For more information on the Connect-PnPOnline cmdlet, please see the official documentation at

Please feel free to share your feedback / suggestion / queries for this article in comment section below.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *