Presentation is loading. Please wait.

Presentation is loading. Please wait.

SharePoint Online and PowerShell?

Similar presentations


Presentation on theme: "SharePoint Online and PowerShell?"— Presentation transcript:

1 SharePoint Online and PowerShell?
Yes, you can! Joseph Ackerman, Dell Inc.

2 About Me Based here in Silicon Valley
Almost 30 years of development experience, 2/3 of it as a consultant on the Microsoft Stack The last 9 years have been mostly SharePoint development for organizations like eBay Fidelity Investments Applied Technologies Verisign The State of Montana Bank of America Currently a member of Dell Services ( )

3 Agenda Scripting On-Premises vs. Scripting Online
Introducing the Office Developers Patterns and Practices Libraries Preparing to Script SharePoint Online Software Requirements Credential Options Code and Demos Reporting and Making Changes to SharePoint Online with PowerShell Resources

4 Scripting On-Premises vs. Scripting Online

5 Scripting On-Premises
You must have access to the underlying physical or virtual servers The script must run on the server itself You must be logged in with a high level of permissions on the server You must set the execution policy to allow scripts to run Your scripts may need to be signed if the system administrator or organizational policy requires it You need to have access to the SharePoint PowerShell Snap-In and include it in your scripts You must have a permission level in SharePoint that is high enough to accomplish the tasks you are attempting in your script code (this is also true in SharePoint Online)

6 Scripting Online We have no access to the underlying servers
The good news is we can run from any computer with the right software installed and an Internet connection We have to use client-side code and libraries No special policy settings are necessary All we need are Office 365 credentials with the appropriate permissions It’s obvious but since we are logging in with our O365 credentials, we need to make sure that they have permission to complete the tasks that we are attempting with our scripts We can consume the same SharePoint client libraries used by .NET and JavaScript

7 Microsoft provides *some* cmdlets
Office 365 Cmdlets for administrative tasks Creating sites Removing sites Adding users Creating groups Etc. us/library/fp aspx

8 Thankfully OfficeDevPnP is working on the rest
PnP Cmdlets to manage artifacts in sites Lists Views Fields Upload files Etc. PowerShell/blob/master/Documentation/re adme.md

9 Introducing the Office Developers Patterns and Practices Libraries

10 What is OfficeDevPnP? A Microsoft-sponsored Community Project
Note: “sponsored”, not “supported”, it’s all open source, available on GitHub Originally formed by a group of consultants working on the transformation of development practices from SharePoint On-Premises to SharePoint Online Transforming SharePoint full Trust Code Solutions to the add-in model An open source community effort with both internal (Microsoft) and external contributors.  Not directly linked with the official Patterns and Practices team at Microsoft Everyone involved is a volunteer, they all have their day jobs (as they are fond of reminding me…) They have an official slide:

11 Sharing is caring… http://aka.ms/OfficeDevPnP Themes Code samples
Guidance documentation Monthly community calls Case Studies Themes SharePoint add-ins Microsoft Graph, Office 365 APIs etc. Remote provisioning Client side development

12 OfficeDevPnP Cmdlets Architecture
The Microsoft SharePoint Client DLLs are the foundation of all remote communications with SharePoint Online. Written in C#, the OfficeDevPnP.Core.DLL encapsulates much of the plumbing and setup required to write remote code against SharePoint Online sites. Much of the functionality is written as extension methods to familiar SharePoint objects (Web, List, etc.), making it very easy for developers to use Also written in C#, the OfficeDevPnP Cmdlets module uses the Core.DLL and brings much of its functionality to PowerShell scripters

13 Available cmdlets Add-SPOContentType Get-SPOAuditing
Get-SPOWebPartProperty Remove-SPOWikiPage Add-SPOContentTypeToDocumentSet Get-SPOAuthenticationRealm Get-SPOWebPartXml Remove-SPOWorkflowDefinition Add-SPOContentTypeToList Get-SPOAzureADManifestKeyCredentials Get-SPOWebTemplates Remove-SPOWorkflowSubscription Add-SPOCustomAction Get-SPOContentType Get-SPOWikiPageContent Request-SPOReIndexList Add-SPOEventReceiver Get-SPOContext Get-SPOWorkflowDefinition Request-SPOReIndexWeb Add-SPOField Get-SPOCustomAction Get-SPOWorkflowSubscription Resume-SPOWorkflowInstance Add-SPOFieldFromXml Get-SPODocumentSetTemplate Import-SPOAppPackage Send-SPOMail Add-SPOFieldToContentType Get-SPOEventReceiver Import-SPOTaxonomy Set-SPOAppSideLoading Add-SPOFile Get-SPOFeature Import-SPOTermGroupFromXml Set-SPOAuditing Add-SPOFolder Get-SPOField Import-SPOTermSet Set-SPOContext Add-SPOHtmlPublishingPageLayout Get-SPOFile Install-SPOSolution Set-SPODefaultColumnValues Add-SPOIndexedProperty Get-SPOGroup New-SPOGroup Set-SPODefaultContentTypeToList Add-SPOJavaScriptBlock Get-SPOGroupPermissions New-SPOList Set-SPODocumentSetField Add-SPOJavaScriptLink Get-SPOHealthScore New-SPOPersonalSite Set-SPOFileCheckedIn Add-SPOListItem Get-SPOHomePage New-SPOProvisioningTemplateFromFolder Set-SPOFileCheckedOut Add-SPOMasterPage Get-SPOIndexedPropertyKeys New-SPOTenantSite Set-SPOGroup Add-SPONavigationNode Get-SPOJavaScriptLink New-SPOTermGroup Set-SPOGroupPermissions Add-SPOPublishingPage Get-SPOList New-SPOUser Set-SPOHomePage Add-SPOPublishingPageLayout Get-SPOListItem New-SPOWeb Set-SPOIndexedProperties Add-SPOTaxonomyField Get-SPOMasterPage Remove-SPOContentType Set-SPOList Add-SPOUserToGroup Get-SPOProperty Remove-SPOContentTypeFromDocumentSet Set-SPOListItem Add-SPOView Get-SPOPropertyBag Remove-SPOContentTypeFromList Set-SPOListPermission Add-SPOWebPartToWebPartPage Get-SPOProvisioningTemplate Remove-SPOCustomAction Set-SPOMasterPage Add-SPOWebPartToWikiPage Get-SPOSearchConfiguration Remove-SPOEventReceiver Set-SPOMinimalDownloadStrategy Add-SPOWikiPage Get-SPOSite Remove-SPOField Set-SPOPropertyBagValue Add-SPOWorkflowDefinition Get-SPOSitePolicy Remove-SPOFieldFromContentType Set-SPOSearchConfiguration Add-SPOWorkflowSubscription Get-SPOSiteSearchQueryResults Remove-SPOFile Set-SPOSitePolicy Apply-SPOProvisioningTemplate Get-SPOStoredCredential Remove-SPOGroup Set-SPOTaxonomyFieldValue Connect-SPOnline Get-SPOSubWebs Remove-SPOIndexedProperty Set-SPOTenantSite Convert-SPOProvisioningTemplate Get-SPOTaxonomyItem Remove-SPOJavaScriptLink Set-SPOTheme Disable-SPOFeature Get-SPOTaxonomySession Remove-SPOList Set-SPOTraceLog Disconnect-SPOnline Get-SPOTenantSite Remove-SPOListItem Set-SPOUserProfileProperty Enable-SPOFeature Get-SPOTermGroup Remove-SPONavigationNode Set-SPOWeb Ensure-SPOFolder Get-SPOTheme Remove-SPOPropertyBagValue Set-SPOWebPartProperty Execute-SPOQuery Get-SPOTimeZoneId Remove-SPOTenantSite Set-SPOWikiPageContent Export-SPOTaxonomy Get-SPOUserProfileProperty Remove-SPOUserFromGroup Stop-SPOWorkflowInstance Export-SPOTermGroupToXml Get-SPOView Remove-SPOView Uninstall-SPOAppInstance Find-SPOFile Get-SPOWeb Remove-SPOWeb Uninstall-SPOSolution Get-SPOAppInstance Get-SPOWebPart Remove-SPOWebPart

14 ‘Old school’ PowerShell
Using CSOM code in PowerShell is convoluted and repetitive Building a client context $basePath = 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI' Add-Type -Path '$basePath\Microsoft.SharePoint.Client.dll' Add-Type -Path '$basePath\Microsoft.SharePoint.Client.Runtime.dll' $url = ' $creds = Get-Credential -Message 'Enter Online Credential' $O365Credential = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($creds.UserName,$creds.Password) $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($url) $ctx.Credentials = $O365Credential # your script

15 ‘New school’ PowerShell
Using CSOM code in PowerShell with the PnP Cmdlets is simple Building a client context $url = ' Connect-SPOnline -Url $url $ctx = Get-SPOContext # your script

16 So what do we need?

17 Software Requirements
All of this requires PowerShell version 3 or higher: (v3) (v4) (v5) The SharePoint Server 2013 Client Components SDK: And the latest PnP PowerShell Commands: In PowerShell v5: Install-Module OfficeDevPnP.PowerShell.V15.Commands Install-Module OfficeDevPnP.PowerShell.V16.Commands For earlier, There are two versions of the commands installer: PnPPowerShellCommands15.msi for SharePoint 2013 on-premises PnPPowerShellCommands16.msi for SharePoint Online / Office 365 Available from

18 Credential Options - Interactive
Nothing happens in SharePoint Online without Credentials… They can be entered interactively at run-time This is fine if you are personally monitoring the run of your script Demo Demo creation of stored credentials with Windows Credential Manager

19 Credential Options – Windows Credential Manager
The PnP PowerShell Cmdlets can use generic credentials stored in Windows Credential Manager Conveniently stored on the machine where the script will be run Referred to by a simple label Excellent if you want to run your scripts unattended, for example as part of a timer job Perfect if you are a lazy typist like me  Demo

20 Demos!

21 aka.ms/OfficeDevPnP https://aka.ms/OfficeDevPnPVideos
@OfficeDevPnP

22


Download ppt "SharePoint Online and PowerShell?"

Similar presentations


Ads by Google