Presentation is loading. Please wait.

Presentation is loading. Please wait.

PowerShell and Office 365 IT Pro #AwesomeSauce

Similar presentations


Presentation on theme: "PowerShell and Office 365 IT Pro #AwesomeSauce"— Presentation transcript:

1 PowerShell and Office 365 IT Pro #AwesomeSauce
Mike Dixon and David Lozzi Boston Office 365 User Group April 20th, 2017

2 Agenda Who are we Introduction to PowerShell Office 365 Administration
Office Dev Patterns and Practices Resources and References

3 Mike Dixon Senior Consultant Office 365 Guru
Wellington Street Consulting Migrated over 51,000 seats to Office 365  Don’t be shy…. @BostonO365

4 David Lozzi Solutions Architect Portals & Collaboration Slalom
Been SharePointing since MOSS 2003, developer since 1997 Don’t be shy…. @DavidLozzi

5 What is PowerShell PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework. src: wikipedia

6 PowerShell History? Version 1 Version 2 Version 3 Version 4 Version 5
Windows XP SP2, 2003 Sp1, Vista Basic Commands Version 2 Windows 7, 2008 R2, XP SP3, 2003 SP2, Vista SP1 Remoting Background Jobs Debugging Try-Catch-Finally Modules Version 3 Windows 8, 2012, 7 SP1, 2008 SP1, 2008 R2 SP1 Part of Windows Management Framework 3.0 Scheduled jobs IntelliSense and Snippets in ISE Automatic Module Detection New Commands Version 4 Windows 8.1, 2012 R2, 7 SP1, 2008 R2 SP1, 2012 Part of Windows Management Framework 4.0 Enhanced debugging Network diagnostics for Hyper-V New default execution policy RemoteSigned New commands Version 5 Windows 10 Part of Windows Management Framework 5.0

7 How to get PowerShell You already have it! Unless you’re running on Windows XP SP1 or older. Our demos today are run on PowerShell 5.1 on Windows 10. What version do you have? Open PowerShell and type in $PSVersionTable

8 Office 365 Administration

9 But this looks like code?!
It’s just commands, nothing crazy Verb-Noun Keep it clean Windows Nano (since 2016) Windows Core (since 2008) Consistency Accessibility Automation

10 Posh vs Embedded Languages
Sometimes it's PowerShell in name only Many languages can be imbedded in Posh If you already know another language start there If you don't, avoid these.

11 The glory of the ISE ISE for newbs Syntax highlighting
Command completion GUI for parameters Modular

12 How to Connect to Office 365
Install Microsoft Online Service Sign In Assistant (MOS SIA) Set execution policy (only command that requires local admin access) Set-ExecutionPolicy RemoteSigned Load module Connect-MsolService -Credential $LiveCred New-CsOnlineSession -Credential $LiveCred There is no dedicated Exchange Online module SERIOUSLY stop running things elevated out of habit. Three reasons you need elevation: 1. setting execution policy 2. installing or updating modules 3. making changes to the local machine

13 Connection gotchas Cannot connect with an account using MFA
Not even App passwords PowerShell accounts do NOT need a license Admin accounts Best Practice Mdixon: has E3, active mbx, no admin, MFA enabled MDixon.posh: no license, global admin, no MFA

14 How to Build Reports Find out what attributes are available
get-mailbox mdixon -properties * | Export-Csv c:\logs\mdixon- all.csv Choose your parameters Export your report $Allinfo | select Mailbox,User,AccessRights,MBXIdentity | Export- Csv -Path C:\Logs\Allinfo-$ScriptName-$today.csv -NoTypeInformation

15 Admin Resources studio.code.org PowerShell.office.com

16 PowerShell 201 Things PowerShell can do but we couldn't fit in this deck Foreach loops Nested foreach loops Arrays IF – Else statements Try – Catch - Finally

17 Office Dev Patterns & Practices

18 Office Dev Patterns & Practices
Developed by Microsoft Consultants migrating users from full trust on-prem solutions to Office 365/SharePoint Online Add-Ins Intro videos Weekly web casts Samples Gallery Training SharePoint Framework, Office 365 APIs, Office Add-Ins, and Microsoft Graph

19 Why should you care? It’s not just for developers!!
PowerShell is Microsoft’s tool for the IT Pro Makes your job easier! Automate mundane tasks across your sites Streamline your governance DevOps practices Streamline deployments from developer teams Automate creation and tear down of development sites And more!

20 Getting Started https://github.com/SharePoint/PnP
PnP at dev.office.com - Welcome page with sample and guidance search SharePoint Dev Group - Questions and feedback PnP at MSDN PnP videos at YouTube PnP at Docs.com - Docs.com PnP Sites Core Component - GitHub repository PnP Core Component (JavaScript) - GitHub repository PnP PowerShell - GitHub repository PnP Partner Pack - Reusable starter kit for typical enterprise requirements PnP Guidance - GitHub repository PnP Office-Addins - GitHub repository PnP Tools - GitHub repository PnP Transformation - GitHub repository PnP Provisioning Schema - GitHub repository

21 Getting started: PnP PowerShell
Windows 10 Install-Module SharePointPnPPowerShellOnline Not on Windows 10? Install PowerShellGet, Download and Install PnP PowerShell

22 What can you do with PnP? Get-Command *pnp* PowerShell/blob/master/Documentation/readme.md

23 Apps (Add, Remove) Publishing (Page layouts, wiki pages, page content) Branding (Custom actions, Set home page, inject JavaScript, set Master Page, modify Navigation, apply Responsive, set Theme) Search (Get and set configuration) Recycle Bin (Get item, clear, restore) Content Types (Add, Remove, Modify) Sites and Webs (Add, remove, auditing, solutions) Libraries, Lists (Add, Remove, Modify, List Items, Document Sets, Files, Folders, Permissions) Taxonomy (Add, Remove, Modify terms, term groups, term sets) Features (Enable, disable) Users and Groups (Add, Remove, Modify) Information Management (Site policy, closure) Web Parts (Add to pages, remove from pages) Groups (Add, Remove, Modify) Provisioning (Create template, apply template, modify template)

24 Let’s do this! No Developer Needed

25 Connecting to SharePoint Online
Connect-PnpOnline url Requires credentials Great for quick connects and updates Connect-PnPOnline url -AppId xxxxx -AppSecret xxxxx Get a client ID and secret to allow your script to automagically connect Share your scripts without sharing your credentials DevOps/Continuous Integration processes can connect and run scripts Connect-PnpOnline url –Credentials $cred I’m getting too lazy to keep typing, save your login for your session You can set $cred = Get-Credential

26 Register your Script as an App
Navigate to the SharePoint site's new app registration page Generate the Client ID and Client Secret, and fill out the remaining fields. Click Create. In the following window, copy the output for your reference. Navigate to the site's app permissions Copy in the Client ID into the App ID Field. Copy in the following XML into the Permission Request XML field: <AppPermissionRequests AllowAppOnlyPolicy="true"> <AppPermissionRequest Scope=" Right="FullControl"/> </AppPermissionRequests> Click Create, then click Trust It

27 Create a new site Connect-PnPOnline Get-PnPTimeZoneId (EST - 10) Get-PnPWebTemplates (Team site - EHS#1) New-PnPTenantSite -Title “Site Title” -Url -Owner -TimeZone 10 -StorageQuota 100 -Template EHS#1

28 Create a New Library Connect-PnPOnline New-PnPList -Title Reports -Template DocumentLibrary – EnableVersioning Add-PnPFolder -Name “Status Reports” -Folder Reports Add-PnPFile -Path “C:\path\to\file\doc.docx” -Folder “Reports/Status Reports” Other systems ing files, reports, data to users? Automate copying files to a SharePoint folder for your users. No more s!

29 Mobile Friendly Site Mobile Friendly Responsive SharePoint Pages
NO DEVELOPER NEEDED Connect-PnPOnline Enable-PnPResponsiveUI Just do it, the out of the box mobile experience is terrible at best.

30 Create your site template
Your template is based off of an existing site. Do what you will, it should catch all of your changes in SharePoint. Connect-PnPOnline Get-PnPProvisioningTemplate -Out bos365template.pnp Coming soon (it’s here but doesn’t work…yet) Add-PnPDataRowsToProvisioningTemplate -Path bos365template.pnp -List Tasks -Query “<View></View>” Add-PnPListFoldersToProvisioningTemplate –Path bos365template.pnp -List Documents –Recursive

31 Apply your site template
Connect-PnPOnline Apply-PnPProvisioningTemplate -Path bos365template.pnp Add-PnPListItem -List Tasks Project"} -ContentType Item Add-PnPFolder -Name Scope -Folder "Shared Documents" You may also apply only certain components of the template by using -handlers i.e. -handlers Features, Pages

32 Add Users and Groups to a Site
Connect-PnPOnline New-PnPGroup -Title “Group Name" -Description “Be descriptive" -Owner Add-PnPUserToGroup –LoginName –Identity “Group Name” Set-PnPGroupPermissions -Identity “Group Name” -AddRole "Full Control" You may set permissions on lists as well using the -list parameter

33 Set Site Policy and Closure
Connect-PnPOnline Set-PnPSitePolicy –Name “Policy Name” Set-PnPSiteClosure -State Closed

34 Piece it all together Create a single PowerShell file to run all of these commands automatically Use ISE, NotePad++, etc. to create a file, Create-Site.ps1

35 Automate Provisioning
Have users submit site requests to a SharePoint list Use Get-PnPListItem to retrieve requests Depending on the request, Connect-PnPOnline to your template site Get-PnPProvisioningTemplate New-PnPTenantSite Connect-PnPOnline to your new site Apply-PnPProvisioningTemplate Add-PnPUserToGroup Send-PnPMail to the requestor

36 Quick Recap Created a new SharePoint Online site Added a Library
Enable mobile-friendly responsive WITHOUT A DEVELOPER! Create a site template Applied a site template Added a group and users to the site Set a site policy Script it Automate Provisioning

37 Office Developer Platform
4/4/2019 6:38 PM aka.ms/OfficeDevPnP @OfficeDevPnP © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

38 Let’s us know how it goes!
Thank you! Let’s us know how it goes!


Download ppt "PowerShell and Office 365 IT Pro #AwesomeSauce"

Similar presentations


Ads by Google