cancel
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
  Type="Text"
  DisplayName="Status"
  Name="fafappstatus">
  <Default>Not started</Default>
</Field>'
Add-PnPFieldFromXml -FieldXml $xml -List $title

 

More information about the initiative can be found here.

Meet Our Blog Authors
Labels