PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with...

Post on 15-Feb-2017

1.627 views 0 download

Transcript of PowerShell Conference Asia: Building your SharePoint On-Premises and Online Solutions with...

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

PowerShell Conference Asia 2015

Hi. I’m Gokan.

Brussels, BELGIUM neoxy.be SharePoint MVP

Community Member @GokanOzcifci http://gokan.ms

PowerShell Conference Asia 2015

Hi. I’m Gilles.

Montpellier, FRANCE smartview.fr Office365 MVP

Community Member @GipIsBack

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

gipomm

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”

PowerShell Conference Asia 2015

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

PowerShell Conference Asia 2015

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

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

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 ………

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.

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")

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

OfficeDev/PnP-PowerShell

PowerShell Conference Asia 2015

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

PowerShell Conference Asia 2015

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

requirements• Single use case

PowerShell Conference Asia 2015

PowerShell• Simple to write• Commonly known

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

PowerShell Conference Asia 2015

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

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();

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"

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"

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)

PowerShell Conference Asia 2015

Office365 Intranet Manager

This is Jacques, Daniel

Using PowerShell with SharePoint 2013

PowerShell Conference Asia 2015

Rule #1 : organize your scriptsProject deployment Folder

Application Files Folder

Launcher

PowerShell Conference Asia 2015

Scripts Folder and Deploy WSP details

PowerShell Conference Asia 2015

Rule #2 - Think SharePoint : Site Deployment Details

PowerShell Conference Asia 2015

PowerShell with SharePoint 2013

Demo

Using PowerShell with SharePoint Online.

PowerShell Conference Asia 2015

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

PowerShell Conference Asia 2015

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

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

PowerShell Conference Asia 2015

Office 365 CmdLets for SharePoint

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

PowerShell Conference Asia 2015

PowerShell with Office 365

Demo

Using PowerShell in Office 365 with Office Dev PnP

PowerShell Conference Asia 2015

PnP-PowerShell commands : where ?

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

PowerShell Conference Asia 2015

PnP-PowerShell commands : what?

PowerShell Conference Asia 2015

PowerShell with OfficeDev PnP

Demo

PowerShell Conference Asia 2015

Tips and Tricks for Powers Hell

Demo

PowerShell Conference Asia 2015

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

PowerShell Conference Asia 2015

What PS commands did I use?

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

PowerShell Conference Asia 2015

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

PowerShell Conference Asia 2015

questions?

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!!!!

PowerShell Conference Asia 2015

thank you.