Difference between
SharePoint Online PowerShell (SPO) and PnP PowerShell
(SPO vs PnP)
Basically, during interview these topics like Difference between SPO and PnP, Connect with SharePoint by PowerShell Command are very common to be discussed. We will start from the Difference between SPO and PnP. At the end, we will also discuss 'How can connect to SharePoint online by using the SPO and PnP commands?'
Question-1 Difference between SPO and PnP?
PnP PowerShell-
- It is managed by Patterns and Practices team.
- It can be used for SharePoint Server as well as SharePoint Online. it means that is a cross platform library.
- It works in context of the current user. It mean that no need to have tenant level /SharePoint administrator right to manage.
- It works at level of site collection.
- It has wide range of commands at Site, List and Item level.
SharePoint Online (SPO)
PowerShell-
- It is managed by Microsoft
- SharePoint Administrator/ Tenant Admin Rights are required to use the SPO.
- It helps to perform the SharePoint administrative task at the tenant level.
- Mostly it works from the tenant level till site level but not at Subsite, List and Item level.
Note- PnP commands
have extra parameters as compare to SPO commands. So, PnP can perform many
SharePoint administrative tasks as compare to the SharePoint Online.
Question-2 How can connect with SharePoint by using the SPO and PnP Commands?
SPO Command-
Connect-SPOService command is used to connect with SharePoint tenant. there are two ways to connect SharePoint. First is Account with MFA or Second is Account Without MFA.
Connect With SharePoint Online Without MFA (Multi Factor Authentication)-
Here ConvertTo- SecureString Window PowerShell command is used to encrypted the Plaint text Password. Password has always a security concern.
#Set the SharePoint admin center URL.
$AdminURL
=
"https://TenantName-admin.sharepoint.com"
$UserName
=
"UserTest@Organize.com"
$Password
=
"Put your Password Here"
$SecurePass
=
ConvertTo-SecureString
$Password
-AsPlainText
-Force
$Cred
=
new-object
-typename
System.Management.Automation.PSCredential
-argumentlist
$UserName
,
$SecurePass
Connect-SPOService
-url
$CenterURL
-Credential
$Credential
#To test that SharePoint is connected, Run the below given command, it will provide the list of site collections
Get-SPOSite
Connect With SharePoint Online With MFA-
If SharePoint Administrator account is MFA enabled, We can not use above mention Script. In MFA, Manually, User has to pass the 6 Digit security Key or in case of Authenticator app need to pass 2 digit security key.
Connect-SPOService
-Url
https://TenantName-admin.sharepoint.com
PnP Command-
Connect-PnPOnline Command is used to connect the SharePoint Site. PnP has amazing capabilities to connect at the SharePoint Site Level. Here There are two ways to connect with SharePoint Online. First is Account With MFA and Second is Account Without MFA.
Connect With SharePoint Online (Site) Without MFA-
$SharePointSiteURL
=
"https://SiteName.sharepoint.com"
$UserID
=
"Current User Name"
$Pass
=
"User password"
$SecurePass
=
ConvertTo-SecureString
-String
$Pass
-AsPlainText
-Force
$Credentials
=
New-Object
-TypeName
System.Management.Automation.PSCredential
-argumentlist
$UserID
,
$SecurePass
#connect the sharepoint site by using PnP Powrshell
Connect-PnPOnline
-Url
$SharePointSiteURL -Credentials
$CredentialsConnect-PnPOnline
-Url
$SharePointSiteURL -UseWebLogin
See, How the SharePoint online is connected by PowerShell
that is covered in this article. SharePoint Administrator must have a good
knowledge of PowerShell to automate the Administrative tasks and some time to
automate the business requirements. PnP has good number of commands to perform
the task at the Site level, List level. But SPO has good control at the tenant
level, Site level.
To perform the task at the tenant level, Use the SPO. Others use PnP for the rest of task.
Comments
Post a Comment