Showing results for 
Search instead for 
Did you mean: 

AMFTF: Script your SharePoint objects with PnP PowerShell

Creating SharePoint objects like lists, site columns and groups using the webbrowser can become quite time consuming, especially when working with multiple environments (like development, test and production).


Some time ago, a community initiative started with the goal to offer PowerShell cmdlets to perform complex provisioning and artifact management actions towards SharePoint. For people who are not familiar with PowerShell: PowerShell is a scripting language used for installation, configuration and automation.


This initiative is called: PnP PowerShell


So why is this useful for PowerApps? Well, there are multiple reasons. It allows you to transfer apps more easily from one environment to another because when executed well, all lists and internal column names are equal meaning you do not have to make changes to your app other than connecting the app to the correct SharePoint lists. You can also use it to add demo data or clean up an environments.


PnP PowerShell also allows you to add site columns with display names which already exist. Something I find particular useful for names like 'Status', 'City' or 'Company'. The internal name must be unique though so I always add a prefix.


I advice everybody who build apps with SharePoint to investigate PnP PowerShell. You will not regret it.


 An example to add a SharePoint list and add a list column to it (after connecting to a site) is given below:


$title = 'PowerApps demo list'
$template = 'GenericList'
$url = 'powerappsdemolist'
$hidden = $false
$enableVersioning = $true
$enableContentTypes = $false
$onQuickLaunch = $true

New-PnPList -Title $title -Template $template -Url $url -Hidden:$hidden -EnableVersioning:$enableVersioning -EnableContentTypes:$enableContentTypes -OnQuickLaunch:$onQuickLaunch

$xml = '<Field
  <Default>Not started</Default>
Add-PnPFieldFromXml -FieldXml $xml -List $title


More information about the initiative can be found here.

Meet Our Blog Authors
  • PowerApps Community Mentor 2018, Practicing surgeon and former Professor of Surgery, University of Illinois, Chicago.
  • I am the Owner/Principal Architect at Don't Pa..Panic Consulting. I've been working in the information technology industry for over 30 years, and have played key roles in several enterprise SharePoint architectural design review, Intranet deployment, application development, and migration projects. I've been a Microsoft Most Valuable Professional (MVP) 12 consecutive years and am also a Microsoft Certified SharePoint Masters (MCSM) since 2013.
  • Systems developer
  • My name is Timothy Shaw and I create digital solutions using the Power Platform, Office 365, and Azure SQL and handle the IT for a small company in the energy sector. When not building the future :), I enjoy playing guitar, good (or really bad!) sci-fi, Xbox therapy, and hanging with my wife and son. Twitter: @ShortForTim