SlideShare a Scribd company logo
1 of 24
PowerShell Basics for
Office Apps & Servers
Greg McMurray
SharePoint Saturday Utah
February 2019
Thank You SPSUtah 2019 Sponsors!
PLATINUM
• Lucidworks
• ZAACT
GOLD
• JourneyTEAM
• Sovereign SP
SILVER
• SkySync
ShareSki & SharePint
Intro – Greg
• Experience in Aerospace, Branding & Marketing,
Energy, Healthcare, Software
• Currently Senior Software Engineer at WECC
• Co-Founder of Aritus Computer Services, L.L.C.
• President of SharePoint / Office 365
and Dynamics 365 User Groups
• Find me online:
- @goyuix
- https://www.linkedin.com/in/goyuix
- https://stackoverflow.com/cv/goyuix
( top 2% of users )
Pluralsight IQ
https://www.pluralsight.com/product/skill-iq
Agenda
•PowerShell History & Basics
•SharePoint Online
•SharePoint PnP Library
•SharePoint On-Premises
•Office Apps Automation
This Photo by Unknown Author is licensed under CC BY-NC-ND
In the beginning
We needed a shell
Not that kind
of shell . . .
Our forebears: CSH
• Hey look! A C-Shell
• We are getting closer
• Created by Bill Joy as a graduate student
at UC Berkeley in the late 1970s
• “reads commands from a file … supports
filename wildcarding, piping, here
documents, command substitution,
variables and control structures for
condition-testing and iteration” – C-Shell,
Wikipedia
This Photo by Unknown Author is licensed under CC BY-SA
PowerShell Origin Story:
Monad & Manifesto
• Monad: Term coined by Leibniz to represent a fundamental
unit of existence, that are combined and composed into for
a purpose
• PowerShell paper in 2002 states: “provide a powerful,
consistent, intuitive, extensible and useful set of tools”
• Game changer: Piping objects instead of text
PowerShell Versions
• 1.0: for XP, Vista and Server 2003
• 2.0: included in Win 7 & Server 2008
• 3.0: included in Win 8 & Server 2012
• 4.0: included in Win 8.1 & Server 2012 R2
• 5.0/5.1: include in Win 10 & Server 2016
• 6.0: Becomes PowerShell Core
PowerShell Basics - cmdlets
•Verb-Noun Syntax
• Examples:
• Get-Help
• Get-Command
• Get-Member
• about* pages
PowerShell Basics - Variables
• Variables are labels that hold values
• Start with a dollar sign
• Values have types
• A bunch of special variables exist:
$ENV, $_, $error, etc.
PowerShell Basics - Piping
• The pipe character: |
•Quite literally “pipes” output from
the left side to the right as input
• Reminder: Everything is an object,
might be a string, or something else
PowerShell Basics - Control
•if () { } else {}
• do { } while ()
• foreach ($item in $stuff) {}
• $stuff | ForEach-Object { $_ }
SharePoint Online Management Shell
• https://docs.microsoft.com/en-us/powershell/sharepoint/sharepoint-
online/connect-sharepoint-online?view=sharepoint-ps
• https://www.powershellgallery.com/packages/Microsoft.Online.Share
Point.PowerShell/
• Remember PowerShell needs elevated / admin permissions
• Install: Install-Module -Name Microsoft.Online.SharePoint.PowerShell
• Verify: Get-Module -Name Microsoft.Online.SharePoint.PowerShell
• Notes: You may need to update NuGet and trust the Gallery
PowerShell - SPO
$email = 'admin@tenant.com’
$url = 'https://tenant-admin.sharepoint.com'
$cred = Get-Credential $email
Connect-SPOService -Url $url -Credential $cred
• Note: If MFA is enabled, just omit the credential parameter and you
will be prompted through the authentication process
SharePoint Patterns and Practices (PnP)
• https://docs.microsoft.com/en-us/powershell/sharepoint/sharepoint-
pnp/sharepoint-pnp-cmdlets?view=sharepoint-ps
• “Perform complex provisioning and artifact management”
• Uses Client Side Object Model (CSOM)
• Three different versions:
• Install-Module SharePointPnPPowerShellOnline
• Install-Module SharePointPnPPowerShell2016
• Install-Module SharePointPnPPowerShell2013
PowerShell - PnP
$url = 'https://your-tenant.sharepoint.com'
$cred = Get-Credential admin@tenant.com
Connect-PnPOnline –Url $url –Credentials $cred
$list = Get-PnPList /Lists/MyCustomList
Set-PnPList –Identity $list –Hidden $true
• Note: If MFA is enabled, change -Credential to -UseWebLogin
On-Premises SharePoint
• https://docs.microsoft.com/en-us/powershell/module/sharepoint-
server/?view=sharepoint-ps
• Uses the SharePoint .NET API
• Must be run on servers that are part of your on-premises farm
PowerShell – On-Premises
# $Host.Runspace.ThreadOptions = "ReuseThread"
# Add-PsSnapin Microsoft.SharePoint.PowerShell
$url = 'https://your-farm.domain.local’
$site = Get-SPSite $url
$site.AllWebs | Select-Object Title,Url
Note: You may need to uncomment the first two lines if you are running the
script outside of the SharePoint Management Shell (it auto-includes them)
Office Apps Automation
• Work with your data and surface it in applications
• A few different approaches are available
• COM / .NET API
• Office OpenXML
• How would you like to work with this data?
PowerShell – Word Automation
# Must have Office installed, bad for servers
$word = New-Object -ComObject word.application
$word.Visible = $true
$word.Documents.Add()
PowerShell – Excel Automation
# https://github.com/dfinke/ImportExcel
Install-Module -Name ImportExcel
Get-Process | Export-Excel
Learning More
• Microsoft and the community have TONS of resources
• Weekly YouTube calls for PnP work
• Channel 9, docs.microsoft.com
• Pluralsight, LinkedIn Learning / Lynda.com, Udemy, others
• Let’s chat: What do you want to build?
• Contact Me: @goyuix or linkedin.com/in/goyuix
• Github: https://github.com/goyuix/presentations/

More Related Content

What's hot

SharePoint Development 101
SharePoint Development 101SharePoint Development 101
SharePoint Development 101
Greg Hurlman
 

What's hot (20)

Apex & jQuery Mobile
Apex & jQuery MobileApex & jQuery Mobile
Apex & jQuery Mobile
 
Wordpress beyond blogging
Wordpress beyond bloggingWordpress beyond blogging
Wordpress beyond blogging
 
AngularJS meets Rails
AngularJS meets RailsAngularJS meets Rails
AngularJS meets Rails
 
How angularjs saves rails
How angularjs saves railsHow angularjs saves rails
How angularjs saves rails
 
Develop a vanilla.js spa you and your customers will love
Develop a vanilla.js spa you and your customers will loveDevelop a vanilla.js spa you and your customers will love
Develop a vanilla.js spa you and your customers will love
 
Best Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsBest Practices for Building WordPress Applications
Best Practices for Building WordPress Applications
 
SharePoint Development 101
SharePoint Development 101SharePoint Development 101
SharePoint Development 101
 
JavaScript front end performance optimizations
JavaScript front end performance optimizationsJavaScript front end performance optimizations
JavaScript front end performance optimizations
 
PLAT-7 Spring Web Scripts and Spring Surf
PLAT-7 Spring Web Scripts and Spring SurfPLAT-7 Spring Web Scripts and Spring Surf
PLAT-7 Spring Web Scripts and Spring Surf
 
Best Practices for WordPress in Enterprise
Best Practices for WordPress in EnterpriseBest Practices for WordPress in Enterprise
Best Practices for WordPress in Enterprise
 
A 20 minute introduction to AngularJS for XPage developers
A 20 minute introduction to AngularJS for XPage developersA 20 minute introduction to AngularJS for XPage developers
A 20 minute introduction to AngularJS for XPage developers
 
Using RESTFUL APIs in ANGULARJS
Using RESTFUL APIs in ANGULARJSUsing RESTFUL APIs in ANGULARJS
Using RESTFUL APIs in ANGULARJS
 
Best Practices for WordPress
Best Practices for WordPressBest Practices for WordPress
Best Practices for WordPress
 
Episerver and search engines
Episerver and search enginesEpiserver and search engines
Episerver and search engines
 
Elastic & Azure & Episever, Case Evira
Elastic & Azure & Episever, Case EviraElastic & Azure & Episever, Case Evira
Elastic & Azure & Episever, Case Evira
 
Externalizing Chatter Using Heroku, Angular.js, Node.js and Chatter REST APIs
Externalizing Chatter Using Heroku, Angular.js, Node.js and Chatter REST APIsExternalizing Chatter Using Heroku, Angular.js, Node.js and Chatter REST APIs
Externalizing Chatter Using Heroku, Angular.js, Node.js and Chatter REST APIs
 
Dfc 2018 NativeScript
Dfc 2018 NativeScriptDfc 2018 NativeScript
Dfc 2018 NativeScript
 
You Got React.js in My PHP
You Got React.js in My PHPYou Got React.js in My PHP
You Got React.js in My PHP
 
Disrupting the application eco system with progressive web applications
Disrupting the application eco system with progressive web applicationsDisrupting the application eco system with progressive web applications
Disrupting the application eco system with progressive web applications
 
PHP, OAuth, Web Services and YQL
PHP, OAuth, Web Services and YQLPHP, OAuth, Web Services and YQL
PHP, OAuth, Web Services and YQL
 

Similar to PowerShell Basics for Office Apps and Servers

Similar to PowerShell Basics for Office Apps and Servers (20)

Mastering Office 365 with PowerShell - TechDays Finland 2020
Mastering Office 365 with PowerShell -  TechDays Finland 2020Mastering Office 365 with PowerShell -  TechDays Finland 2020
Mastering Office 365 with PowerShell - TechDays Finland 2020
 
D2 - Automate Custom Solutions Deployment on Office 365 and Azure - Paolo Pia...
D2 - Automate Custom Solutions Deployment on Office 365 and Azure - Paolo Pia...D2 - Automate Custom Solutions Deployment on Office 365 and Azure - Paolo Pia...
D2 - Automate Custom Solutions Deployment on Office 365 and Azure - Paolo Pia...
 
SPSTC - PowerShell - Through the SharePoint Looking Glass
SPSTC - PowerShell - Through the SharePoint Looking GlassSPSTC - PowerShell - Through the SharePoint Looking Glass
SPSTC - PowerShell - Through the SharePoint Looking Glass
 
Introduction to PowerShell for SharePoint Admins and Developers
Introduction to PowerShell for SharePoint Admins and DevelopersIntroduction to PowerShell for SharePoint Admins and Developers
Introduction to PowerShell for SharePoint Admins and Developers
 
PowerShell Introduction to Administering SharePoint On-Premises & O365
PowerShell Introduction to Administering SharePoint On-Premises & O365PowerShell Introduction to Administering SharePoint On-Premises & O365
PowerShell Introduction to Administering SharePoint On-Premises & O365
 
SPSSTL - PowerShell - Through the SharePoint Looking Glass
SPSSTL - PowerShell - Through the SharePoint Looking GlassSPSSTL - PowerShell - Through the SharePoint Looking Glass
SPSSTL - PowerShell - Through the SharePoint Looking Glass
 
Introduction to PowerShell - Be a PowerShell Hero - SPFest workshop
Introduction to PowerShell - Be a PowerShell Hero - SPFest workshopIntroduction to PowerShell - Be a PowerShell Hero - SPFest workshop
Introduction to PowerShell - Be a PowerShell Hero - SPFest workshop
 
O365Con18 - Hybrid SharePoint Deep Dive - Thomas Vochten
O365Con18 - Hybrid SharePoint Deep Dive - Thomas VochtenO365Con18 - Hybrid SharePoint Deep Dive - Thomas Vochten
O365Con18 - Hybrid SharePoint Deep Dive - Thomas Vochten
 
SPSNL17 - Implementing SharePoint hybrid search, start to finish - Thomas Voc...
SPSNL17 - Implementing SharePoint hybrid search, start to finish - Thomas Voc...SPSNL17 - Implementing SharePoint hybrid search, start to finish - Thomas Voc...
SPSNL17 - Implementing SharePoint hybrid search, start to finish - Thomas Voc...
 
I6 - State of the art SharePoint PowerShell Nation 2017 - Spencer Harbar
I6 - State of the art SharePoint PowerShell Nation 2017 - Spencer HarbarI6 - State of the art SharePoint PowerShell Nation 2017 - Spencer Harbar
I6 - State of the art SharePoint PowerShell Nation 2017 - Spencer Harbar
 
Utilizing jQuery in SharePoint: Get More Done Faster
Utilizing jQuery in SharePoint: Get More Done FasterUtilizing jQuery in SharePoint: Get More Done Faster
Utilizing jQuery in SharePoint: Get More Done Faster
 
SharePoint Saturday New York: PowerShell for Office 365
SharePoint Saturday New York: PowerShell for Office 365SharePoint Saturday New York: PowerShell for Office 365
SharePoint Saturday New York: PowerShell for Office 365
 
Managing SharePoint Anywhere with Windows PowerShell
Managing SharePoint Anywhere with Windows PowerShellManaging SharePoint Anywhere with Windows PowerShell
Managing SharePoint Anywhere with Windows PowerShell
 
Spsatx slides (widescreen)
Spsatx slides (widescreen)Spsatx slides (widescreen)
Spsatx slides (widescreen)
 
SPO Migration - New API
SPO Migration - New APISPO Migration - New API
SPO Migration - New API
 
Office 365 & PowerShell - A match made in heaven
Office 365 & PowerShell - A match made in heavenOffice 365 & PowerShell - A match made in heaven
Office 365 & PowerShell - A match made in heaven
 
SPugPt Meeting 35: Manage govern and drive adoption of share point online wit...
SPugPt Meeting 35: Manage govern and drive adoption of share point online wit...SPugPt Meeting 35: Manage govern and drive adoption of share point online wit...
SPugPt Meeting 35: Manage govern and drive adoption of share point online wit...
 
SharePoint 2013 App or Not to App
SharePoint 2013 App or Not to AppSharePoint 2013 App or Not to App
SharePoint 2013 App or Not to App
 
Introduction to PowerShell at Chicago Code Camp 2014
Introduction to PowerShell at Chicago Code Camp 2014Introduction to PowerShell at Chicago Code Camp 2014
Introduction to PowerShell at Chicago Code Camp 2014
 
The Path through SharePoint Migrations
The Path through SharePoint MigrationsThe Path through SharePoint Migrations
The Path through SharePoint Migrations
 

More from Greg McMurray

More from Greg McMurray (11)

Power Platform Introduction - Utah PowerApps and Flow User Group
Power Platform Introduction - Utah PowerApps and Flow User GroupPower Platform Introduction - Utah PowerApps and Flow User Group
Power Platform Introduction - Utah PowerApps and Flow User Group
 
SharePoint Search - August 2019 at Utah SharePoint User Group
SharePoint Search - August 2019 at Utah SharePoint User GroupSharePoint Search - August 2019 at Utah SharePoint User Group
SharePoint Search - August 2019 at Utah SharePoint User Group
 
Introduction to SQL Server Graph DB
Introduction to SQL Server Graph DBIntroduction to SQL Server Graph DB
Introduction to SQL Server Graph DB
 
Power BI Streaming Datasets - San Diego BI Users Group
Power BI Streaming Datasets - San Diego BI Users GroupPower BI Streaming Datasets - San Diego BI Users Group
Power BI Streaming Datasets - San Diego BI Users Group
 
Dynamics 365 Web API - CRMUG April 2018
Dynamics 365 Web API - CRMUG April 2018Dynamics 365 Web API - CRMUG April 2018
Dynamics 365 Web API - CRMUG April 2018
 
SQL Server Temporal Tables
SQL Server Temporal TablesSQL Server Temporal Tables
SQL Server Temporal Tables
 
Sql Server 2016 and JSON
Sql Server 2016 and JSONSql Server 2016 and JSON
Sql Server 2016 and JSON
 
Power BI Streaming Datasets
Power BI Streaming DatasetsPower BI Streaming Datasets
Power BI Streaming Datasets
 
Introduction to Microsoft Teams
Introduction to Microsoft TeamsIntroduction to Microsoft Teams
Introduction to Microsoft Teams
 
CRMUG Presentation on Dynamics CRM integration with SharePoint
CRMUG Presentation on Dynamics CRM integration with SharePointCRMUG Presentation on Dynamics CRM integration with SharePoint
CRMUG Presentation on Dynamics CRM integration with SharePoint
 
Real World Power Query for Excel and Power BI - SQL Saturday #576
Real World Power Query for Excel and Power BI - SQL Saturday #576Real World Power Query for Excel and Power BI - SQL Saturday #576
Real World Power Query for Excel and Power BI - SQL Saturday #576
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Recently uploaded (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 

PowerShell Basics for Office Apps and Servers

  • 1. PowerShell Basics for Office Apps & Servers Greg McMurray SharePoint Saturday Utah February 2019
  • 2. Thank You SPSUtah 2019 Sponsors! PLATINUM • Lucidworks • ZAACT GOLD • JourneyTEAM • Sovereign SP SILVER • SkySync ShareSki & SharePint
  • 3. Intro – Greg • Experience in Aerospace, Branding & Marketing, Energy, Healthcare, Software • Currently Senior Software Engineer at WECC • Co-Founder of Aritus Computer Services, L.L.C. • President of SharePoint / Office 365 and Dynamics 365 User Groups • Find me online: - @goyuix - https://www.linkedin.com/in/goyuix - https://stackoverflow.com/cv/goyuix ( top 2% of users )
  • 5. Agenda •PowerShell History & Basics •SharePoint Online •SharePoint PnP Library •SharePoint On-Premises •Office Apps Automation This Photo by Unknown Author is licensed under CC BY-NC-ND
  • 6. In the beginning We needed a shell
  • 7. Not that kind of shell . . .
  • 8. Our forebears: CSH • Hey look! A C-Shell • We are getting closer • Created by Bill Joy as a graduate student at UC Berkeley in the late 1970s • “reads commands from a file … supports filename wildcarding, piping, here documents, command substitution, variables and control structures for condition-testing and iteration” – C-Shell, Wikipedia This Photo by Unknown Author is licensed under CC BY-SA
  • 9. PowerShell Origin Story: Monad & Manifesto • Monad: Term coined by Leibniz to represent a fundamental unit of existence, that are combined and composed into for a purpose • PowerShell paper in 2002 states: “provide a powerful, consistent, intuitive, extensible and useful set of tools” • Game changer: Piping objects instead of text
  • 10. PowerShell Versions • 1.0: for XP, Vista and Server 2003 • 2.0: included in Win 7 & Server 2008 • 3.0: included in Win 8 & Server 2012 • 4.0: included in Win 8.1 & Server 2012 R2 • 5.0/5.1: include in Win 10 & Server 2016 • 6.0: Becomes PowerShell Core
  • 11. PowerShell Basics - cmdlets •Verb-Noun Syntax • Examples: • Get-Help • Get-Command • Get-Member • about* pages
  • 12. PowerShell Basics - Variables • Variables are labels that hold values • Start with a dollar sign • Values have types • A bunch of special variables exist: $ENV, $_, $error, etc.
  • 13. PowerShell Basics - Piping • The pipe character: | •Quite literally “pipes” output from the left side to the right as input • Reminder: Everything is an object, might be a string, or something else
  • 14. PowerShell Basics - Control •if () { } else {} • do { } while () • foreach ($item in $stuff) {} • $stuff | ForEach-Object { $_ }
  • 15. SharePoint Online Management Shell • https://docs.microsoft.com/en-us/powershell/sharepoint/sharepoint- online/connect-sharepoint-online?view=sharepoint-ps • https://www.powershellgallery.com/packages/Microsoft.Online.Share Point.PowerShell/ • Remember PowerShell needs elevated / admin permissions • Install: Install-Module -Name Microsoft.Online.SharePoint.PowerShell • Verify: Get-Module -Name Microsoft.Online.SharePoint.PowerShell • Notes: You may need to update NuGet and trust the Gallery
  • 16. PowerShell - SPO $email = 'admin@tenant.com’ $url = 'https://tenant-admin.sharepoint.com' $cred = Get-Credential $email Connect-SPOService -Url $url -Credential $cred • Note: If MFA is enabled, just omit the credential parameter and you will be prompted through the authentication process
  • 17. SharePoint Patterns and Practices (PnP) • https://docs.microsoft.com/en-us/powershell/sharepoint/sharepoint- pnp/sharepoint-pnp-cmdlets?view=sharepoint-ps • “Perform complex provisioning and artifact management” • Uses Client Side Object Model (CSOM) • Three different versions: • Install-Module SharePointPnPPowerShellOnline • Install-Module SharePointPnPPowerShell2016 • Install-Module SharePointPnPPowerShell2013
  • 18. PowerShell - PnP $url = 'https://your-tenant.sharepoint.com' $cred = Get-Credential admin@tenant.com Connect-PnPOnline –Url $url –Credentials $cred $list = Get-PnPList /Lists/MyCustomList Set-PnPList –Identity $list –Hidden $true • Note: If MFA is enabled, change -Credential to -UseWebLogin
  • 19. On-Premises SharePoint • https://docs.microsoft.com/en-us/powershell/module/sharepoint- server/?view=sharepoint-ps • Uses the SharePoint .NET API • Must be run on servers that are part of your on-premises farm
  • 20. PowerShell – On-Premises # $Host.Runspace.ThreadOptions = "ReuseThread" # Add-PsSnapin Microsoft.SharePoint.PowerShell $url = 'https://your-farm.domain.local’ $site = Get-SPSite $url $site.AllWebs | Select-Object Title,Url Note: You may need to uncomment the first two lines if you are running the script outside of the SharePoint Management Shell (it auto-includes them)
  • 21. Office Apps Automation • Work with your data and surface it in applications • A few different approaches are available • COM / .NET API • Office OpenXML • How would you like to work with this data?
  • 22. PowerShell – Word Automation # Must have Office installed, bad for servers $word = New-Object -ComObject word.application $word.Visible = $true $word.Documents.Add()
  • 23. PowerShell – Excel Automation # https://github.com/dfinke/ImportExcel Install-Module -Name ImportExcel Get-Process | Export-Excel
  • 24. Learning More • Microsoft and the community have TONS of resources • Weekly YouTube calls for PnP work • Channel 9, docs.microsoft.com • Pluralsight, LinkedIn Learning / Lynda.com, Udemy, others • Let’s chat: What do you want to build? • Contact Me: @goyuix or linkedin.com/in/goyuix • Github: https://github.com/goyuix/presentations/