{"id":919,"date":"2018-10-09T06:25:54","date_gmt":"2018-10-09T06:25:54","guid":{"rendered":"https:\/\/www.tatvasoft.com.au\/blog\/?p=919"},"modified":"2022-03-17T07:49:24","modified_gmt":"2022-03-17T07:49:24","slug":"remote-administration-of-sharepoint-with-pnp-powershell","status":"publish","type":"post","link":"https:\/\/www.tatvasoft.com.au\/blog\/remote-administration-of-sharepoint-with-pnp-powershell\/","title":{"rendered":"Remote Administration of SharePoint with PnP-PowerShell"},"content":{"rendered":"<p>From the title of the blog, the first question comes in mind is \u201cWhat is PowerShell?\u201d<\/p>\n<p>The answer is: It is an object-oriented automation engine and scripting language developed by Microsoft and built on the .Net framework. It has an interactive command-line shell where the user can execute commands to fulfill their tasks.<span id=\"more-1105\"><\/span><\/p>\n<p>It\u2019s mainly used in configuring systems and automate administrative tasks. Actually, PowerShell and PnP-PowerShell scripts are highly used by SharePoint administrators and SharePoint developers can run large and bulk operations on sites. For example, add large data in SharePoint lists, apply permissions to users in sites, etc. Below scenario is often concluded while SharePoint consulting.<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1163\" title=\"PnP PowerShell\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/PnP-PowerShell.jpg\" sizes=\"(max-width: 685px) 100vw, 685px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/PnP-PowerShell.jpg 685w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/PnP-PowerShell-300x150.jpg 300w\" alt=\"PnP PowerShell\" width=\"685\" height=\"342\" \/><\/p>\n<h2>Scenario<\/h2>\n<p>For on-premise servers: Sometimes client provides SharePoint administrator access of site but without remote desktop access connectivity so we cannot take RDP session to run PowerShell scripts for managing SharePoint sites. In this case, we can log in to one of the client\u2019s machines which are connected to SharePoint farm domain and after that, we can run PnP-PowerShell cmdlets for SharePoint site management which is not possible with conventional PowerShell scripts.<\/p>\n<p>PowerShell scripts are based on the .Net framework so for execution, they are highly dependable on Microsoft OS versions where PnP-PowerShell is platform independent which means the user can run cmdlets from their Mac or Linux machines to manage SharePoint sites.<\/p>\n<p>SharePoint administrators majorly use PowerShell scripting to manage SharePoint servers. Authorized administrators can perform a wide variety of operations in SharePoint On-premise and SharePoint Online by executing cmdlets (pronounced \u201ccommand-lets\u201d).<\/p>\n<p>Microsoft provides cmdlets for these 2 systems:<\/p>\n<ul>\n<li>List of cmdlets for SharePoint On-premise server: <a href=\"https:\/\/docs.microsoft.com\/en-us\/powershell\/module\/sharepoint-server\/index?view=sharepoint-ps\" rel=\"nofollow\">SharePoint Server PowerShell<\/a><\/li>\n<li>List of cmdlets for SharePoint Online: <a href=\"https:\/\/docs.microsoft.com\/en-us\/powershell\/module\/sharepoint-online\/index?view=sharepoint-ps\" rel=\"nofollow\">SharePoint Online PowerShell<\/a><\/li>\n<\/ul>\n<h2>The SharePoint Development Community<\/h2>\n<p>Commonly known as \u201cSharePoint PnP Community\u201d (PnP stands for Patterns and Practices) which is an open source initiative coordinated by the SharePoint engineering team. This community controls documentation, reusable controls and samples related to <a href=\"https:\/\/www.tatvasoft.com.au\/technologies\/sharepoint-development\/\">SharePoint development<\/a>. Enthusiast developers or users can contribute their efforts in this community via <a href=\"https:\/\/github.com\/SharePoint\/\" rel=\"nofollow\">GitHub<\/a>. It is community driven open source project where Microsoft and external members can share their learning and implementation practices for Office, Office 365 and SharePoint servers. It was first started with guidance in the SharePoint add-in model and then evolves with other areas like SharePoint framework, Microsoft graph API, Office add-ins and Office 365 APIs.<\/p>\n<p>Let\u2019s talk about PowerShell commands prepared by the PnP community commonly known as PnP-PowerShell.<\/p>\n<h2>PnP-PowerShell<\/h2>\n<p>Microsoft has already provided a library of PowerShell commands for SharePoint On-premise servers and SharePoint Online along with separate command-line Shell. The question appears in mind that \u201c<strong>What is PnP-PowerShell and what is the use of it?<\/strong>\u201d<\/p>\n<p>SharePoint Patterns and Practices contains a library of PowerShell commands to ease the life of SharePoint administrators who can perform complex tasks in minutes with the new PnP PowerShell commands. These commands use CSOM and work for both SharePoint Online and SharePoint On-premise servers.<\/p>\n<p>Most amazing and facilitating feature of PnP-PowerShell is <strong>cross-platform execution<\/strong>. PowerShell cmdlets used for SharePoint before were Microsoft OS dependent but now, you can use PnP-PowerShell with different platforms like Mac and Linux.<\/p>\n<p>One of the benefits behind <strong>CSOM commands<\/strong> for SharePoint On-premise servers is that an administrator can use cmdlets without logged-in to servers which means the administrator can access servers from any machine\u2019s PowerShell command prompt which is connected with same domain in the same farm.<\/p>\n<p>PnP-PowerShell provides something we can call \u201c<strong>Context Switching<\/strong>\u201d. For example, you are connected to the SharePoint Online site. Now you want to do some admin side operations. With old SharePoint Online cmdlets, you need to first close the connection for the current site and after that, you need to create the context to connect to admin site using different URL (i.e.: https:\/\/admin.sharepoint.com). With PnP-PowerShell cmdlets, you can easily connect to admin site without creating the new context or closing older context.<\/p>\n<p>PnP-PowerShell cmdlets:<\/p>\n<div class=\"wp_syntax\" style=\"position: relative;\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"javascript\" style=\"font-family: monospace;\">Connect<span style=\"color: #339933;\">-<\/span>PnPOnline https<span style=\"color: #339933;\">:<\/span><span style=\"color: #006600; font-style: italic;\">\/\/contoso.sharepoint.com<\/span>\r\nGet<span style=\"color: #339933;\">-<\/span>PnPLis\r\nGet<span style=\"color: #339933;\">-<\/span>PnPTenantSite<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p class=\"theCode\" style=\"display: none;\">Connect-PnPOnline https:\/\/contoso.sharepoint.com Get-PnPLis Get-PnPTenantSite<\/p>\n<\/div>\n<p>Using the 1st line, you are connected to the SharePoint Online site. In 2nd line, you get all lists from the site. And using the 3rd line, you are now connected to SharePoint admin site.\u00a0 It creates a clone of context during execution of the 3rd line, to use further in operations. So there is no need do new connection for admin site using commands.<\/p>\n<p>Let\u2019s start installation without wasting much time.<\/p>\n<h2>Installation<\/h2>\n<h3>Prerequisites<\/h3>\n<ul>\n<li>If you are using <strong>Windows Server 2012 R2 OS<\/strong>. Normally, this OS has PowerShell version 4. You require to upgrade PowerShell to version 5. Kindly download setup file from below URL to upgrade PowerShell:\u00a0 https:\/\/www.microsoft.com\/en-us\/download\/details.aspx?id=54616<\/li>\n<li>You need to be a local administrator to run PowerShell as an administrator.<\/li>\n<li>Set execution policy to allow to run remote scripts.<\/li>\n<\/ul>\n<h3>Steps:<\/h3>\n<ul>\n<li>Run <code>get-executionpolicy<\/code> PowerShell command to get status of execution policy as shown below:<img loading=\"lazy\" class=\"aligncenter wp-image-1109 size-full\" style=\"max-width: 100%; height: auto;\" title=\"Run get-executionpolicy\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/get-executionpolicy.jpg\" sizes=\"(max-width: 572px) 100vw, 572px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/get-executionpolicy.jpg 572w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/get-executionpolicy-300x76.jpg 300w\" alt=\"Run get-executionpolicy \" width=\"572\" height=\"145\" \/><\/li>\n<\/ul>\n<ul>\n<li>If it\u2019s not set to \u201cRemote signed\u201d. Then set it by this command:<code>set-executionpolicy remotesigned<\/code><img loading=\"lazy\" class=\"aligncenter wp-image-1110 size-full\" style=\"max-width: 100%; height: auto;\" title=\"Set-executionpolicy remotesigned\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/Set-executionpolicy-remotesigned.jpg\" sizes=\"(max-width: 577px) 100vw, 577px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/Set-executionpolicy-remotesigned.jpg 577w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/Set-executionpolicy-remotesigned-300x100.jpg 300w\" alt=\"Set-executionpolicy remotesigned\" width=\"577\" height=\"193\" \/><\/li>\n<li>Need appropriate permissions in SharePoint Online or in SharePoint server.<\/li>\n<\/ul>\n<p><em><strong>Note:<\/strong><\/em> After performing the required operations through PnP cmdlets, set the execution policy from \u201cRemote signed\u201d to the original one i.e. the output of the <code>get-executionpolicy<\/code> cmdlets.<\/p>\n<h2>Install Setup<\/h2>\n<h3>First approach: PowerShell Gallery<\/h3>\n<p>If your main OS is Windows 10, or if you have <a href=\"https:\/\/github.com\/powershell\/powershellget\" rel=\"nofollow\">PowerShellGet<\/a> installed, you can run the following commands to install package according to your environment need:<\/p>\n<table class=\"blog-table\">\n<thead>\n<tr>\n<th><b>SharePoint Version<\/b><\/th>\n<th><b>Command to install<\/b><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>SharePoint Online<\/td>\n<td>Install-Module<br \/>\nSharePointPnPPowerShellOnline<\/td>\n<\/tr>\n<tr>\n<td>SharePoint 2016<\/td>\n<td>Install-Module<br \/>\nSharePointPnPPowerShell2016<\/td>\n<\/tr>\n<tr>\n<td>SharePoint 2013<\/td>\n<td>Install-Module<br \/>\nSharePointPnPPowerShell2013<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Here are some warnings or error messages with workarounds you might face during installation:<\/p>\n<ul>\n<li>Sometimes for On-premise servers, if it gives below warning:Warning: user declined to install untrusted module SharePoint PNP PowerShellUse \u201c-Force\u201d attribute after the command:e.g.: <code>Install-Module SharePointPnPPowerShell2013 \u2013Force<\/code><\/li>\n<li>Error message: PackageManagement\\Install-Package: The version \u2018x.x.x.x\u2019 of the module \u2018SharePointPnPPowerShellOnline\u2019 being installed is not catalog signed. Use below cmdlet:e.g.:\u00a0 <code>Install-Module SharePointPnPPowerShellOnline -SkipPublisherCheck -AllowClobber<\/code><\/li>\n<\/ul>\n<h3>Second approach: Setup files<\/h3>\n<p>Download setup files from <a href=\"https:\/\/github.com\/sharepoint\/pnp-powershell\/releases\" rel=\"nofollow\">releases<\/a>. It will provide different setup file for SharePoint 2013, 2016 and SharePoint Online. Install it according to your server needs. After installation, you need to restart the open instance of PowerShell.<\/p>\n<h3>Third approach: Installation script<\/h3>\n<p>It will require at least PowerShell v3 installed in the machine. You can check the version of PowerShell by running <code>$PSVersionTable.PSVersion<\/code>.<\/p>\n<p>To install the cmdlets you need to run below command, which will install PowerShell Package Management and modules from PowerShell Gallery.<\/p>\n<div class=\"wp_syntax\" style=\"position: relative;\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"javascript\" style=\"font-family: monospace;\">Invoke<span style=\"color: #339933;\">-<\/span>Expression <span style=\"color: #009900;\">(<\/span>New<span style=\"color: #339933;\">-<\/span>ObjectNet.<span style=\"color: #660066;\">WebClient<\/span><span style=\"color: #009900;\">)<\/span>.<span style=\"color: #660066;\">DownloadString<\/span><span style=\"color: #009900;\">(<\/span><span style=\"color: #3366cc;\">'https:\/\/raw.githubusercontent.com\/sharepoint\/PnP-PowerShell\/master\/Samples\/Modules.Install\/Install-SharePointPnPPowerShell.ps1'<\/span><span style=\"color: #009900;\">)<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p class=\"theCode\" style=\"display: none;\">Invoke-Expression (New-ObjectNet.WebClient).DownloadString(&#8216;https:\/\/raw.githubusercontent.com\/sharepoint\/PnP-PowerShell\/master\/Samples\/Modules.Install\/Install-SharePointPnPPowerShell.ps1&#8217;)<\/p>\n<\/div>\n<h3>Install Updates<\/h3>\n<p>Every month a release will be available for cmdlets. You can install the latest updated version using below commands:<\/p>\n<p><code>Update-Module SharePointPnPPowerShell*<\/code><\/p>\n<p>You can check installed PnP-PowerShell versions with the following command:<\/p>\n<div class=\"wp_syntax\" style=\"position: relative;\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"javascript\" style=\"font-family: monospace;\">Get<span style=\"color: #339933;\">-<\/span>Module SharePointPnPPowerShell<span style=\"color: #339933;\">*<\/span> <span style=\"color: #339933;\">-<\/span>ListAvailable\r\n<span style=\"color: #339933;\">|<\/span> Select<span style=\"color: #339933;\">-<\/span>Object Name<span style=\"color: #339933;\">,<\/span>Version <span style=\"color: #339933;\">|<\/span> Sort<span style=\"color: #339933;\">-<\/span>Object Version \u2013Descending<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p class=\"theCode\" style=\"display: none;\">Get-Module SharePointPnPPowerShell* -ListAvailable | Select-Object Name,Version | Sort-Object Version \u2013Descending<\/p>\n<\/div>\n<h3>Output:<\/h3>\n<p><img loading=\"lazy\" class=\"aligncenter wp-image-1115 size-full\" title=\"SharePointPnPPowerShell\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/SharePointPnPPowerShell.jpg\" sizes=\"(max-width: 625px) 100vw, 625px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/SharePointPnPPowerShell.jpg 625w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/SharePointPnPPowerShell-300x89.jpg 300w\" alt=\"SharePointPnPPowerShell\" width=\"625\" height=\"185\" \/><\/p>\n<h2>Getting Started<\/h2>\n<h3>Connect to SharePoint Online site with PnP-PowerShell<\/h3>\n<ul>\n<li>Let\u2019s connect to SharePoint Online Site with below command:\n<div class=\"wp_syntax\" style=\"position: relative;\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"javascript\" style=\"font-family: monospace;\">Connect<span style=\"color: #339933;\">-<\/span>PnPOnline \u2013Url https<span style=\"color: #339933;\">:<\/span><span style=\"color: #006600; font-style: italic;\">\/\/&amp;lt;tenant_name&amp;gt;.sharepoint.com \u2013Credentials (Get-Credential)<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p class=\"theCode\" style=\"display: none;\">Connect-PnPOnline \u2013Url https:\/\/&amp;lt;tenant_name&amp;gt;.sharepoint.com \u2013Credentials (Get-Credential)<\/p>\n<\/div>\n<p><img loading=\"lazy\" class=\"aligncenter wp-image-1116 size-full\" style=\"max-width: 100%; height: auto;\" title=\"PowerShell Credentials\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/PowerShell-Credentials.jpg\" sizes=\"(max-width: 599px) 100vw, 599px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/PowerShell-Credentials.jpg 599w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/PowerShell-Credentials-300x179.jpg 300w\" alt=\"PowerShell Credentials\" width=\"599\" height=\"357\" \/><\/p>\n<p><em><strong>Note:<\/strong><\/em> If you are using multi-factor authentication on your tenant, use below command:<\/p>\n<div class=\"wp_syntax\" style=\"position: relative; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"javascript\" style=\"font-family: monospace;\">Connect<span style=\"color: #339933;\">-<\/span>PnPOnline <span style=\"color: #339933;\">-<\/span>Url https<span style=\"color: #339933;\">:<\/span><span style=\"color: #006600; font-style: italic;\">\/\/&amp;lt;tenant_name&amp;gt;.sharepoint.com -UseWebLogin<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p class=\"theCode\" style=\"display: none;\">Connect-PnPOnline -Url https:\/\/&amp;lt;tenant_name&amp;gt;.sharepoint.com -UseWebLogin<\/p>\n<\/div>\n<\/li>\n<li>You can see all cmdlets provided by PnP with below command:\n<div class=\"wp_syntax\" style=\"position: relative;\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"javascript\" style=\"font-family: monospace;\">Get<span style=\"color: #339933;\">-<\/span>Command <span style=\"color: #339933;\">-<\/span>Module <span style=\"color: #339933;\">*<\/span>PnPPowerShellOnline<span style=\"color: #339933;\">*<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p class=\"theCode\" style=\"display: none;\">Get-Command -Module *PnPPowerShellOnline*<\/p>\n<\/div>\n<\/li>\n<\/ul>\n<h3>Output:<\/h3>\n<p><img loading=\"lazy\" class=\"aligncenter wp-image-1117 size-full\" style=\"max-width: 100%; height: auto;\" title=\"PnPPowerShellOnline\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/PnPPowerShellOnline.jpg\" sizes=\"(max-width: 604px) 100vw, 604px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/PnPPowerShellOnline.jpg 604w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/PnPPowerShellOnline-300x220.jpg 300w\" alt=\"PnPPowerShellOnline\" width=\"604\" height=\"443\" \/><\/p>\n<p>In 3.1.1809.0 version, there are 348 commands available to manage SharePoint Online.Create one custom list and perform CRUD operations<\/p>\n<ul>\n<li>Connect to site using above commands.<strong>Create custom list<\/strong><\/li>\n<li>Using below command, get all lists from SharePoint site.\n<div class=\"wp_syntax\" style=\"position: relative;\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"javascript\" style=\"font-family: monospace;\">Get<span style=\"color: #339933;\">-<\/span>PnPList<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p class=\"theCode\" style=\"display: none;\">Get-PnPList<\/p>\n<\/div>\n<h3>Output:<\/h3>\n<p><img loading=\"lazy\" class=\"aligncenter wp-image-1118 size-full\" style=\"max-width: 100%; height: auto;\" title=\"Get-PnPList\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/Get-PnPList.jpg\" sizes=\"(max-width: 602px) 100vw, 602px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/Get-PnPList.jpg 602w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/Get-PnPList-300x219.jpg 300w\" alt=\"Get-PnPList\" width=\"602\" height=\"440\" \/><\/li>\n<li>Create new list with below command:\n<div class=\"wp_syntax\" style=\"position: relative;\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"javascript\" style=\"font-family: monospace;\">$listName<span style=\"color: #339933;\">=<\/span><span style=\"color: #3366cc;\">\"NewPnPList\"<\/span>\u00a0\u00a0 New<span style=\"color: #339933;\">-<\/span>PnPList <span style=\"color: #339933;\">-<\/span>Title $listName <span style=\"color: #339933;\">-<\/span>Url <span style=\"color: #3366cc;\">\"NewPnPList\"<\/span> <span style=\"color: #339933;\">-<\/span>Template GenericList <span style=\"color: #339933;\">-<\/span>EnableVersioning<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p class=\"theCode\" style=\"display: none;\">$listName=&#8221;NewPnPList&#8221;\u00a0\u00a0 New-PnPList -Title $listName -Url &#8220;NewPnPList&#8221; -Template GenericList -EnableVersioning<\/p>\n<\/div>\n<p><img loading=\"lazy\" class=\"aligncenter wp-image-1119 size-full\" style=\"max-width: 100%; height: auto;\" title=\"NewPnPList\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/NewPnPList.jpg\" sizes=\"(max-width: 587px) 100vw, 587px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/NewPnPList.jpg 587w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/NewPnPList-300x69.jpg 300w\" alt=\"NewPnPList\" width=\"587\" height=\"135\" \/><\/li>\n<\/ul>\n<h2>Create fields in new list<\/h2>\n<ul>\n<li>Using below commands, 2 fields will be created in list:\n<div class=\"wp_syntax\" style=\"position: relative;\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"javascript\" style=\"font-family: monospace;\">$listName<span style=\"color: #339933;\">=<\/span><span style=\"color: #3366cc;\">\"NewPnPList\"<\/span>\r\nAdd<span style=\"color: #339933;\">-<\/span>PnPField <span style=\"color: #339933;\">-<\/span>List $listName <span style=\"color: #339933;\">-<\/span>DisplayName NameHF <span style=\"color: #339933;\">-<\/span>InternalName NameHF <span style=\"color: #339933;\">-<\/span>Type Text <span style=\"color: #339933;\">-<\/span>AddToDefaultView\r\n$choices<span style=\"color: #339933;\">=<\/span><span style=\"color: #3366cc;\">\"Sofware Developer\"<\/span><span style=\"color: #339933;\">,<\/span><span style=\"color: #3366cc;\">\"Sofware Tester\"<\/span><span style=\"color: #339933;\">,<\/span><span style=\"color: #3366cc;\">\"Release Manager\"<\/span>\r\nAdd<span style=\"color: #339933;\">-<\/span>PnPField <span style=\"color: #339933;\">-<\/span>List $listName <span style=\"color: #339933;\">-<\/span>DisplayName RoleHF <span style=\"color: #339933;\">-<\/span>InternalName RoleHF <span style=\"color: #339933;\">-<\/span>Type Choice <span style=\"color: #339933;\">-<\/span>Choices $choices <span style=\"color: #339933;\">-<\/span>AddToDefaultView<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p class=\"theCode\" style=\"display: none;\">$listName=&#8221;NewPnPList&#8221; Add-PnPField -List $listName -DisplayName NameHF -InternalName NameHF -Type Text -AddToDefaultView $choices=&#8221;Sofware Developer&#8221;,&#8221;Sofware Tester&#8221;,&#8221;Release Manager&#8221; Add-PnPField -List $listName -DisplayName RoleHF -InternalName RoleHF -Type Choice -Choices $choices -AddToDefaultView<\/p>\n<\/div>\n<p><img loading=\"lazy\" class=\"aligncenter wp-image-1120 size-full\" style=\"max-width: 100%; height: auto;\" title=\"Add-PnPField\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/Add-PnPField.jpg\" sizes=\"(max-width: 628px) 100vw, 628px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/Add-PnPField.jpg 628w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/Add-PnPField-300x112.jpg 300w\" alt=\"Add-PnPField\" width=\"628\" height=\"234\" \/><\/p>\n<h3>Output:<\/h3>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1122\" style=\"max-width: 100%; height: auto;\" title=\"Output NewPnPList\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/NewPnPList-Output.png.jpg\" sizes=\"(max-width: 629px) 100vw, 629px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/NewPnPList-Output.png.jpg 629w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/NewPnPList-Output.png-300x103.jpg 300w\" alt=\"NewPnPList Output.png\" width=\"629\" height=\"216\" \/><\/li>\n<\/ul>\n<h2>Create new item in list<\/h2>\n<ul>\n<li>Create new item using below command:\n<div class=\"wp_syntax\" style=\"position: relative;\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"javascript\" style=\"font-family: monospace;\">Add<span style=\"color: #339933;\">-<\/span>PnPListItem <span style=\"color: #339933;\">-<\/span>List <span style=\"color: #3366cc;\">\"NewPnPList\"<\/span> <span style=\"color: #339933;\">-<\/span>Values <span style=\"color: #339933;\">@<\/span><span style=\"color: #009900;\">{<\/span><span style=\"color: #3366cc;\">\"Title\"<\/span> <span style=\"color: #339933;\">=<\/span> <span style=\"color: #3366cc;\">\"Test 1\"<\/span><span style=\"color: #339933;\">;<\/span> <span style=\"color: #3366cc;\">\"NameHF\"<\/span><span style=\"color: #339933;\">=<\/span><span style=\"color: #3366cc;\">\"Name 1\"<\/span><span style=\"color: #339933;\">;<\/span> <span style=\"color: #3366cc;\">\"RoleHF\"<\/span><span style=\"color: #339933;\">=<\/span><span style=\"color: #3366cc;\">\"Software Developer\"<\/span><span style=\"color: #009900;\">}<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p class=\"theCode\" style=\"display: none;\">Add-PnPListItem -List &#8220;NewPnPList&#8221; -Values @{&#8220;Title&#8221; = &#8220;Test 1&#8221;; &#8220;NameHF&#8221;=&#8221;Name 1&#8221;; &#8220;RoleHF&#8221;=&#8221;Software Developer&#8221;}<\/p>\n<\/div>\n<p><img loading=\"lazy\" class=\"aligncenter wp-image-1123 size-full\" style=\"max-width: 100%; height: auto;\" title=\"Add-PnPListItem\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/Add-PnPListItem.jpg\" sizes=\"(max-width: 598px) 100vw, 598px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/Add-PnPListItem.jpg 598w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/Add-PnPListItem-300x69.jpg 300w\" alt=\"Add-PnPListItem\" width=\"598\" height=\"138\" \/><\/p>\n<h3>Output:<\/h3>\n<p><img loading=\"lazy\" class=\"aligncenter wp-image-1124 size-full\" style=\"max-width: 100%; height: auto;\" title=\"Create new Item\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/Create-new-Item.jpg\" sizes=\"(max-width: 491px) 100vw, 491px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/Create-new-Item.jpg 491w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/Create-new-Item-300x166.jpg 300w\" alt=\"Create new Item\" width=\"491\" height=\"272\" \/><\/li>\n<\/ul>\n<h2>Update existing item<\/h2>\n<ul>\n<li>Update title of existing item using below command. Here, ID of list item is used for identity.\n<div class=\"wp_syntax\" style=\"position: relative;\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"javascript\" style=\"font-family: monospace;\">Set<span style=\"color: #339933;\">-<\/span>PnPListItem <span style=\"color: #339933;\">-<\/span>List <span style=\"color: #3366cc;\">\"NewPnPList\"<\/span> <span style=\"color: #339933;\">-<\/span>Identity <span style=\"color: #cc0000;\">1<\/span> <span style=\"color: #339933;\">-<\/span>Values <span style=\"color: #339933;\">@<\/span><span style=\"color: #009900;\">{<\/span><span style=\"color: #3366cc;\">\"NameHF\"<\/span> <span style=\"color: #339933;\">=<\/span> <span style=\"color: #3366cc;\">\"John Doe\"<\/span><span style=\"color: #009900;\">}<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p class=\"theCode\" style=\"display: none;\">Set-PnPListItem -List &#8220;NewPnPList&#8221; -Identity 1 -Values @{&#8220;NameHF&#8221; = &#8220;John Doe&#8221;}<\/p>\n<\/div>\n<p><img loading=\"lazy\" class=\"aligncenter wp-image-1125 size-full\" title=\"Set-PnPListItem\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/Set-PnPListItem.jpg\" sizes=\"(max-width: 596px) 100vw, 596px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/Set-PnPListItem.jpg 596w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/Set-PnPListItem-300x104.jpg 300w\" alt=\"Set-PnPListItem\" width=\"596\" height=\"207\" \/><\/p>\n<h3>Output:<\/h3>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1126\" style=\"max-width: 100%; height: auto;\" title=\"Set-PnPListItem Output\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/Set-PnPListItem-Output.jpg\" sizes=\"(max-width: 579px) 100vw, 579px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/Set-PnPListItem-Output.jpg 579w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/Set-PnPListItem-Output-300x133.jpg 300w\" alt=\"Set-PnPListItem Output\" width=\"579\" height=\"257\" \/><\/li>\n<\/ul>\n<h2>Delete existing item<\/h2>\n<ul>\n<li>Delete list item using below command. Here, ID of list item is used for identity.\n<div class=\"wp_syntax\" style=\"position: relative;\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"javascript\" style=\"font-family: monospace;\">Remove<span style=\"color: #339933;\">-<\/span>PnPListItem <span style=\"color: #339933;\">-<\/span>List <span style=\"color: #3366cc;\">\"NewPnPList\"<\/span> <span style=\"color: #339933;\">-<\/span>Identity <span style=\"color: #cc0000;\">1<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p class=\"theCode\" style=\"display: none;\">Remove-PnPListItem -List &#8220;NewPnPList&#8221; -Identity 1<\/p>\n<\/div>\n<p><img loading=\"lazy\" class=\"aligncenter wp-image-1127 size-full\" style=\"max-width: 100%; height: auto;\" title=\"Remove-PnPListItem\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/Remove-PnPListItem.jpg\" sizes=\"(max-width: 545px) 100vw, 545px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/Remove-PnPListItem.jpg 545w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/Remove-PnPListItem-300x117.jpg 300w\" alt=\"Remove-PnPListItem\" width=\"545\" height=\"212\" \/><\/p>\n<h3>Output:<\/h3>\n<p><img loading=\"lazy\" class=\"aligncenter wp-image-1128 size-full\" style=\"max-width: 100%; height: auto;\" title=\"Remove-PnPListItem Output\" src=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/Remove-PnPListItem-Output.jpg\" sizes=\"(max-width: 545px) 100vw, 545px\" srcset=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/Remove-PnPListItem-Output.jpg 545w, https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/Remove-PnPListItem-Output-300x172.jpg 300w\" alt=\"Remove-PnPListItem Output\" width=\"545\" height=\"312\" \/><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>From the title of the blog, the first question comes in mind is \u201cWhat is PowerShell?\u201d The answer is: It&#8230;<\/p>\n","protected":false},"author":1,"featured_media":1198,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[29],"tags":[],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v15.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Remote Administration of SharePoint with PnP Community<\/title>\n<meta name=\"description\" content=\"PowerShell and PnP-PowerShell scripts are highly used by SharePoint administrators and SharePoint developers can run large and bulk operations on sites\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.tatvasoft.com.au\/blog\/remote-administration-of-sharepoint-with-pnp-powershell\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Remote Administration of SharePoint with PnP Community\" \/>\n<meta property=\"og:description\" content=\"PowerShell and PnP-PowerShell scripts are highly used by SharePoint administrators and SharePoint developers can run large and bulk operations on sites\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.tatvasoft.com.au\/blog\/remote-administration-of-sharepoint-with-pnp-powershell\/\" \/>\n<meta property=\"og:site_name\" content=\"TatvaSoft AU Blog\" \/>\n<meta property=\"article:published_time\" content=\"2018-10-09T06:25:54+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-03-17T07:49:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/remote-administration-of-sharepoint-withpnp-powershell.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"750\" \/>\n\t<meta property=\"og:image:height\" content=\"375\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\">\n\t<meta name=\"twitter:data1\" content=\"6 minutes\">\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.tatvasoft.com.au\/blog\/#website\",\"url\":\"https:\/\/www.tatvasoft.com.au\/blog\/\",\"name\":\"TatvaSoft AU Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/www.tatvasoft.com.au\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.tatvasoft.com.au\/blog\/remote-administration-of-sharepoint-with-pnp-powershell\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/www.tatvasoft.com.au\/blog\/wp-content\/uploads\/2018\/10\/remote-administration-of-sharepoint-withpnp-powershell.jpg\",\"width\":750,\"height\":375,\"caption\":\"SharePoint with Patterns and Practices-PowerShell\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.tatvasoft.com.au\/blog\/remote-administration-of-sharepoint-with-pnp-powershell\/#webpage\",\"url\":\"https:\/\/www.tatvasoft.com.au\/blog\/remote-administration-of-sharepoint-with-pnp-powershell\/\",\"name\":\"Remote Administration of SharePoint with PnP Community\",\"isPartOf\":{\"@id\":\"https:\/\/www.tatvasoft.com.au\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.tatvasoft.com.au\/blog\/remote-administration-of-sharepoint-with-pnp-powershell\/#primaryimage\"},\"datePublished\":\"2018-10-09T06:25:54+00:00\",\"dateModified\":\"2022-03-17T07:49:24+00:00\",\"author\":{\"@id\":\"https:\/\/www.tatvasoft.com.au\/blog\/#\/schema\/person\/99be98dec950f3b1cdc014df166dd95c\"},\"description\":\"PowerShell and PnP-PowerShell scripts are highly used by SharePoint administrators and SharePoint developers can run large and bulk operations on sites\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.tatvasoft.com.au\/blog\/remote-administration-of-sharepoint-with-pnp-powershell\/\"]}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.tatvasoft.com.au\/blog\/#\/schema\/person\/99be98dec950f3b1cdc014df166dd95c\",\"name\":\"tatvasoftadmin\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.tatvasoft.com.au\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/1ef69a3ae4a620ca0f649d8228bece0b?s=96&d=mm&r=g\",\"caption\":\"tatvasoftadmin\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/www.tatvasoft.com.au\/blog\/wp-json\/wp\/v2\/posts\/919"}],"collection":[{"href":"https:\/\/www.tatvasoft.com.au\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tatvasoft.com.au\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tatvasoft.com.au\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tatvasoft.com.au\/blog\/wp-json\/wp\/v2\/comments?post=919"}],"version-history":[{"count":52,"href":"https:\/\/www.tatvasoft.com.au\/blog\/wp-json\/wp\/v2\/posts\/919\/revisions"}],"predecessor-version":[{"id":1966,"href":"https:\/\/www.tatvasoft.com.au\/blog\/wp-json\/wp\/v2\/posts\/919\/revisions\/1966"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.tatvasoft.com.au\/blog\/wp-json\/wp\/v2\/media\/1198"}],"wp:attachment":[{"href":"https:\/\/www.tatvasoft.com.au\/blog\/wp-json\/wp\/v2\/media?parent=919"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tatvasoft.com.au\/blog\/wp-json\/wp\/v2\/categories?post=919"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tatvasoft.com.au\/blog\/wp-json\/wp\/v2\/tags?post=919"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}