powershell conference asia: building your sharepoint on-premises and online solutions with...

45

Click here to load reader

Upload: gokan-ozcifci-mvp

Post on 15-Feb-2017

1.627 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

Jul 18th and 19th September 2015

PowerShell Conference Asia 2015

Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOMGokan OzcifciGilles Pommier

Page 2: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

Hi. I’m Gokan.

Brussels, BELGIUM neoxy.be SharePoint MVP

Community Member @GokanOzcifci http://gokan.ms

Page 3: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

Hi. I’m Gilles.

Montpellier, FRANCE smartview.fr Office365 MVP

Community Member @GipIsBack

http://blogs.codes-sources.com/

gipomm

Page 4: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

Agenda• Introduction to SharePoint Server.• Using PowerShell with SharePoint Online.• Custom Framework creation #ProvsContra.• DevOps with PowerShell in Office 365.• OfficeDev/PnP-PowerShell. • Tips and Tricks for “Powers Hell”

Page 5: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

Giftseach twit about us (@gokanozcifci or @gipisback) will win a prize:

Page 6: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

Getting started• Announced at Ignite 2015• http://powershell.office.com• Sets of samples, scenarios, guides, …

Page 7: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

What do you need ?• An Office 365 tenant• Administrator privileges on your Office 365

tenant• Administrator privileges on your machine

running PowerShell• Administration modules

• Microsoft Online Services Sign-in Assistant• Azure Active Directory Module• SharePoint Online Module

• On-Premises• Farm Administrator

Page 8: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

What is SharePoint• It’s a platform

• For collaboration• Enterprise Content Management (ECM)• Centralizing stuff• With a lot of offloaded services• But, chaos due to ………

Page 9: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

Why PoSH for SharePoint Server• Every SharePoint Administrator needs this!• Fast and Flexible

• Get all sites in SharePoint• Get all quota’s on a specific Web Application.

• The MSFT standard for Scripting.• Automation is the future (large deployments).• Hidden features.• No more Next. Next. Finish Ideologies anymore.

Page 10: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

PowerShell the basics• cmdlet

• pronounced "command-let“• More than what

central administration can do• More Control• More Efficiency• More Productivity

Office 365: Import-Module microsoft.online.sharepoint.Powershell

On-Premises 2010+:C:\...\14 or 15\CONFIG\

POWERSHELL\Registration\SharePoint.ps1

2007:[void]

[System.Reflection.Assembly]::LoadWith

PartialName("Microsoft.SharePoint")

Page 11: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

Things to know: Permissions• Must have SharePoint_Shell_Access role on

SharePoint databases (both content & configuration)

• Must be a member of WSS_ADMIN_WPG local group on all farm servers

• Use Add-SPShellAdmin to give a user above permissions

Page 12: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

OfficeDev/PnP-PowerShell

Page 13: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

Page 14: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

Click deployments• Much effort• Time consuming • An Unexpected Error has occurred • Difficult to repeat and reproduce• Not everything is exposed to the User Interface

Page 15: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

Command line app• Requires code / development skills• More Difficult to adjust to changing

requirements• Single use case

Page 16: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

PowerShell• Simple to write• Commonly known

• Many blog posts• Easy to adjust scripts to changing requirements

Page 17: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

Office Dev PnP Cmdlets• Open Source• Community effort• Free

Page 18: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

Old School PowerShellAdd-Type –Path 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll’

$url=https://gokan.sharepoint.com/sites/PnP

$O365Credential= new-object Microsoft.SharePoint.Client.SharePointOnlineCredentials($creds.UserName,$creds.Password)$ctx= new-object Microsoft.SharePoint.Client.ClientContext($url)$ctx.Credentials = $O365Credential…$fieldXml="<Field Type=""Choice"" Name=""SPSLocation"" DisplayName=""Location"" ID=""{ba27f512-27bc-4d07-bdd4-2ee61bc5bcb4}"" Group=""Demo Group"“ Required=""TRUE""><CHOICES><CHOICE>Brussels</CHOICE><CHOICE>Belgium</CHOICE><CHOICE>Paris</CHOICE></CHOICES></Field>$field= $list.Fields.AddFieldAsXml ($fieldXml, $true, [Microsoft.SharePoint.Client.AddFieldOptions]::AddFieldToDefaultView);

$ctx.Load($list);$ctx.ExecuteQuery();

Page 19: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

‘New School’ PowerShell

Connect-SPOnline -Url https://gokan.sharepoint.com/sites/PnP -Credentials GOKANNew-SPOList –Title "Demo list" –Template GenericList -Url lists/demoAdd-SPOField –List "Demo list" `

-DisplayName "Location" `-InternalName "SPSLocation" `-Type Choice `-Group "Demo Group" `-AddToDefaultView `-Choices "Brussels", "Belgium", "Paris"

Page 20: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

Adding and setting a new theme to a siteConnect-SPOnline –Url https://tenant.sharepoint.comAdd-SPOFile –Path C:\theme.spcolor –Folder "_catalogs/theme/15"Add-SPOFile –Path C:\image.jpg –Folder "SiteAssets"

Set-SPOTheme ` –ColorPaletteUrl "/_catalogs/theme/15/theme.spcolor" `-BackgroundImageUrl "/SiteAssets/image.jpg"

Page 21: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

Working with PowerShell.Commands• 123 new Cmdlets Delivered by Office Dev

Patterns & Practices• Uses the OfficeDevPnP.Core framework• Needs to be installed on your machine (more

complex than a simple module)

Page 22: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

Office365 Intranet Manager

This is Jacques, Daniel

Page 23: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

Using PowerShell with SharePoint 2013

Page 24: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

Rule #1 : organize your scriptsProject deployment Folder

Application Files Folder

Launcher

Page 25: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

Scripts Folder and Deploy WSP details

Page 26: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

Rule #2 - Think SharePoint : Site Deployment Details

Page 27: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

PowerShell with SharePoint 2013

Demo

Page 28: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

Using PowerShell with SharePoint Online.

Page 29: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

PowerShell : SharePoint Online and CSOM• CSOM vs Server Object Model

Page 30: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

New from Microsoft : the PowerShell and O365 reference • http://powershell.office.com

Page 31: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

« PowerShell » & Office 365 # Exchange Online$exchSession = New-PSSession `–ConfigurationName Microsoft.Exchange `-ConnectionUri https://ps.outlook.com/powershell `-Credential $c `-Authentication Basic `–AllowRedirectionImport-PSSession $exchSession –AllowClobber

# SharePoint Import-Module Microsoft.Online.Sharepoint.PowerShellConnect-SPOService -Url https://tenant-admin.sharepoint.com/ -Credential $c

Module Azure Active Directory (MSOnline)

# Skype for Business (aka Lync Online) Import-Module LyncOnlineConnector$skypeSession = New-CsOnlineSession -Credential $cImport-PSSession $skypeSession –AllowClobber

Page 32: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

Office 365 CmdLets for SharePoint

Page 33: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

Office 365 PowerShell site creation

Then what to do ? • You can easily use CSOM with the SPO Cmdlets• Use the Cmdlets to get to the Site Collection level• Use CSOM to get into the Webs level

Page 34: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

PowerShell with Office 365

Demo

Page 35: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

Using PowerShell in Office 365 with Office Dev PnP

Page 36: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

PnP-PowerShell commands : where ?

https://github.com/OfficeDev/PnP-PowerShell

Page 37: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

PnP-PowerShell commands : what?

Page 38: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

PowerShell with OfficeDev PnP

Demo

Page 39: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

Tips and Tricks for Powers Hell

Demo

Page 40: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

Find lost application pool passwordscmd.exe /c $env:windir\system32\inetsrv\appcmd.exe list apppool “SharePoint - 80" /text:ProcessModel.Password

Page 41: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

What PS commands did I use?

Get-History | Select –Expand CommandLine | Out-File script.ps1

Page 42: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

Find a new job, through PowerShell stop-computer -force | Get-ADComputer -Filter *

Page 43: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

questions?

Page 44: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

Don’t Forget!• Fill in your survey – it’s how we do

better!• Don’t lose you badge! You need it

for the Social Events• Grab the Speakers for a chat –

they all have time for you!• Let everyone know what they are

missing on Social Media#PowerShell#PSConfAsia

Tweets (preferably with Pictures) win Prizes!!!!

Page 45: PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with PowerShell and CSOM

PowerShell Conference Asia 2015

thank you.