1 / 38

PowerShell and Office 365 IT Pro # AwesomeSauce

PowerShell and Office 365 IT Pro # AwesomeSauce. Mike Dixon and David Lozzi Boston Office 365 User Group April 20 th , 2017. Agenda. Who are we Introduction to PowerShell Office 365 Administration Office Dev Patterns and Practices Resources and References. Mike Dixon. Senior Consultant

haroldl
Download Presentation

PowerShell and Office 365 IT Pro # AwesomeSauce

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. PowerShell and Office 365IT 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 Mike.Dixon@BostonO365.com www.BostonO365.com www.linkedin.com/in/o365guru

  4. David Lozzi Solutions Architect Portals & Collaboration Slalom Been SharePointing since MOSS 2003, developer since 1997 Don’t be shy…. @DavidLozzi david.lozzi@slalom.com www.davidlozzi.com www.linkedin.com/in/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?

  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-ExecutionPolicyRemoteSigned • 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 DevPatterns & 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 • https://dev.office.com/patterns-and-practices • 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 • https://github.com/SharePoint/PnP-PowerShell • Windows 10 • Install-Module SharePointPnPPowerShellOnline • Not on Windows 10? • Install PowerShellGet, https://github.com/powershell/powershellget • Download and Install PnP PowerShell

  22. What can you do with PnP? • Get-Command *pnp* • https://github.com/SharePoint/PnP-PowerShell/blob/master/Documentation/readme.md

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

  24. Let’s do this! No Developer Needed

  25. Connecting to SharePoint Online • Connect-PnpOnlineurl • Requires credentials • Great for quick connects and updates • Connect-PnPOnlineurl -AppIdxxxxx -AppSecretxxxxx • 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-PnpOnlineurl –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 • https://tenant.sharepoint.com/sites/sitename/_layouts/15/appregnew.aspx • 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 • https://tenant.sharepoint.com/sites/sitename/_layouts/15/appinv.aspx • Copy in the Client ID into the App ID Field. • Copy in the following XML into the Permission Request XML field: <AppPermissionRequestsAllowAppOnlyPolicy="true"> <AppPermissionRequest Scope="http://sharepoint/content/sitecollection" Right="FullControl"/> </AppPermissionRequests> • Click Create, then click Trust It

  27. Create a new site • Connect-PnPOnline https://tenant.sharepoint.com/sites/sitename • Get-PnPTimeZoneId (EST - 10) • Get-PnPWebTemplates (Team site - EHS#1) • New-PnPTenantSite -Title “Site Title” -Url https://tenant.sharepoint.com/teams/sitename -Owner user@tenant.sharepoint.com -TimeZone 10 -StorageQuota 100 -Template EHS#1

  28. Create a New Library • Connect-PnPOnline https://tenant.sharepoint.com/sites/sitename • 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 emailing files, reports, data to users? Automate copying files to a SharePoint folder for your users. No more emails!

  29. Mobile Friendly Site Mobile Friendly Responsive SharePoint Pages NO DEVELOPER NEEDED • Connect-PnPOnline https://tenant.sharepoint.com/sites/sitename • 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 https://tenant.sharepoint.com/sites/template • 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 https://tenant.sharepoint.com/sites/sitename • Apply-PnPProvisioningTemplate -Path bos365template.pnp • Add-PnPListItem -List Tasks -Values @{"Title"="Setup 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 https://tenant.sharepoint.com/sites/sitename • New-PnPGroup -Title “Group Name" -Description “Be descriptive" -Owner user@domain.com • Add-PnPUserToGroup –LoginNameuser@domain.com –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 https://tenant.sharepoint.com/sites/sitename • 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-PnPOnlineto your new site • Apply-PnPProvisioningTemplate • Add-PnPUserToGroup • Send-PnPMailto 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. aka.ms/OfficeDevPnP https://github.com/OfficeDev/PnP https://github.com/OfficeDev/PnP-Sites-Core https://github.com/OfficeDev/PnP-PowerShell https://github.com/OfficeDev/PnP-Tools https://github.com/OfficeDev/PnP-Guidance https://github.com/OfficeDev/PnP-Transformation https://github.com/OfficeDev/PnP-Tools https://github.com/OfficeDev/PnP-OfficeAddIns https://github.com/OfficeDev/PnP-Provisioning-Schema https://aka.ms/OfficeDevPnPVideos https://aka.ms/OfficeDevPnPMSDN https://aka.ms/OfficeDevPnPYammer @OfficeDevPnP https://aka.ms/OfficeDevPnPPartnerPack https://aka.ms/OfficeDevPnPCall

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

More Related