The SharePoint / Office 365 Developer Patterns and Practices (PnP) initiative provides a massive array of guidance, code samples and most often used by me, a PnP PowerShell command set that makes working with SharePoint (Online and on-prem) that much easier. General documentation and samples are available direct from GitHub and elsewhere , but I found I need to keep providing the same command references again and again. Therefore I provide the following list of commands and samples as a reference of what I find I use most commonly.

Prerequisites

First of course always ensure that you have the SharePoint PnP PowerShell commands installed. You can follow the installation instructions from the SharePoint PnP PowerShell GitHub repo .

Import PnP PowerShell module if it isn’t already loaded C:\> Import-Module Microsoft.Online.Sharepoint.PowerShell Check to see if PnP PowerShell is installed, and review available PnP commands C:\> Get-Command -Module *PnP*
SharePoint / Office 365 Dev Patterns and Practices (PnP) Common PowerShell Comma ...
Get credentials (i.e. username and password) and save this in a varialbe for repeated use

Connecting to SharePoint is simple enough, but often I prefer to get and temporarily store my login credentials for reuse, i.e. during script debugging.

C:\> $credential = Get-credential
SharePoint / Office 365 Dev Patterns and Practices (PnP) Common PowerShell Comma ...
Connect to a SharePoint site using stored credentials

In the following example, I am asked to provide credentials and then using these credentials (stored in the variable, “$credential”), PowerShell will connect to my sample site in question, http://pixelmill-intranet/.

C:\> $credential = Get-credential C:\> Connect-SPOnline -url http://pixelmill-intranet/ -Credential $credential Enable a trace log for debugging

Want to debug a script? no problem, set the SPOTraceLog

C:\> Set-SPOTraceLog -On -Level Debug Export a provisioning template

One of my favorite reasons to use PnP PowerShell is for site and site asset provisioning. You can also export a provisioning template from an existing SharePoint site.

In the following example, I am exporting a provisioning template from an example SharePoint Online site. You will want to change three primary variables to enable this to work for you. You could create a PS script with parameters based on the sample below.

$tenant : Set this to your specific SharePoint Online tenant sub domain. In this example, my tenant URL is: https://MOD513885.sharepoint.com, thus $tenant will be set the value of “MOD513885″.

$sourceSite : The path to the site to export. I am going to export from a marketing site I created, thus “/sites/marketing”.

$path : The path on your workstation where you want to save the exported provisioning template.

$credential = Get-credential # Define variables $tenant = "MOD513885"; $sourceSite = "/sites/marketing"; $path = "C:\provision-test\MyPnPTemplate.xml"; # Get context to the site in question $webUrl = "https://{0}.sharepoint.com{1}/" -f $tenant, $sourceSite; Write-Output $("Connecting to {0}..." -f $webUrl); Connect-SPOnline -Url $webUrl -Credentials $credential; Write-Output "Context obtained"; # Extract template Write-Output "Creating PnP template..."; Get-SPOProvisioningTemplate -Out $path; Write-Output $("Template saved to {0}" f $path); Apply a provisioning Template

My go to source for applying a provisioning template is straight to the PnP PowerShell GitHub documentation.

https://github.com/SharePoint/PnP-PowerShell/blob/master/Documentation/ApplyPnPProvisioningTemplate.md Apply-SPOProvisioningTemplate Provisioning template valid handlers

Provisioning templates may have a set of handlers that may then be selectively applied to a particular site during provisioning. The best list of handlers I have found is directly in the source code for the Handler model .

https://github.com/SharePoint/PnP-Sites-Core/blob/master/Core/OfficeDevPnP.Core/Framework/Provisioning/Model/Handlers.cs

An evergreen post

As I continue to find more common threads in how I work with PnP PowerShell and what questions I continue to receive, I will update this post to keep it current.

本文系统(windows)相关术语:三级网络技术 计算机三级网络技术 网络技术基础 计算机网络技术

主题: PowerShellGitGitHubOffice
分页:12
转载请注明
本文标题:SharePoint / Office 365 Dev Patterns and Practices (PnP) Common PowerShell Comma ...
本站链接:http://www.codesec.net/view/523046.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(windows) | 评论(0) | 阅读(36)