SlideShare a Scribd company logo
Online Conference
June 17th and 18th 2015
WWW.SPBIZCONF.COM
Introduction to PowerShell
For SharePoint Admins and Developers
WWW.SPBIZCONF.COM
Who is Michael Blumenthal?
• Technical Evangelist, PSC Group
• 20 years in IT Consulting
• 12 years with SharePoint
• 8 years with PowerShell
• Twitter: @MichaelBL
Online Conference
June 17th and 18th 2015
No
Compiling!
No
Packaging!
Command
Line Control!
Online Conference
June 17th and 18th 2015
• It’s Easy to Get Started!1
• Learn the PowerShell Syntax2
• PowerShell + SharePoint3
• Real World Examples4
• More Resources5
Online Conference
June 17th and 18th 2015
Chapter 1
Online Conference
June 17th and 18th 2015
2003
2008,R2
2012, R2
10
7, 8, 8.1, 10
WWW.SPBIZCONF.COM
The Command Line Window
WWW.SPBIZCONF.COM
WWW.SPBIZCONF.COM
The Integrated Script Editor
WWW.SPBIZCONF.COM
PowerShell V3&4 ISE
WWW.SPBIZCONF.COM
POSH vs the SharePoint Mgmt Shells
Online Conference
June 17th and 18th 2015
Chapter 2
WWW.SPBIZCONF.COM
Symbols, Keywords, and Syntax!
Oh My!
• Variables1
• Commands2
• Piping3
• Comparisons4
• Flow Control5
• Filtering6
WWW.SPBIZCONF.COM
Reading Symbols in Code
• (tal Guidance
• Moe, Larry, and }
• The universe started with
the Big !
• !Important
• A # of Bacon and # Browns
WWW.SPBIZCONF.COM
1. Variables!
• Case Insensitive, Dynamic typing
$something
$true, $false, $null, $profile
$myMessage= “Hello, World”
1
Online Conference
June 17th and 18th 2015
WWW.SPBIZCONF.COM
2. Commands are called cmdlets.
Verb-Noun
Built-in, Extensible
Get-Help & Help
Get-Member
WWW.SPBIZCONF.COM
Online Conference
June 17th and 18th 2015
Discoverability
WWW.SPBIZCONF.COM
3. The Power of Piping!
Output Of
Command 1
Input of
Command 2
WWW.SPBIZCONF.COM
Example
WWW.SPBIZCONF.COM
4. Dial zero for an…4
Operator
-eq -le
-ne -like
-gt -notlike
-ge -match
-lt -notmatch
WWW.SPBIZCONF.COM
Example
WWW.SPBIZCONF.COM
5. Taking Control of the Flow
• For (Init;Test;Repeat) {Commands}
• for($i=1; $i -le 10; $i++) {Write-Host $i}For
• Foreach (Item in Collection) {Commands}
• Foreach ($web in $site.AllWebs) {$web.Title}ForEach
• If (Test) {Commands}
• if ($web.Title –ne “”) {Write-Host $web.Title}If
• While (Condition){Commands}
• while($val -ne 3){$val++; Write-Host $val}While
Online Conference
June 17th and 18th 2015
Example
WWW.SPBIZCONF.COM
6. Where-Object
•Where {<Test>}Syntax
• V1&2:Dir | Where {$_.Name –like
“B*”}
• V3:Dir | where Name –like B*
Example
WWW.SPBIZCONF.COM
Executing Scripts
.filename.ps1
Set-ExecutionPolicy
Unrestricted
Online Conference
June 17th and 18th 2015
Chapter 3
WWW.SPBIZCONF.COM
Version of
SharePoint?
O365
D/L SOMC
•Get GLP Scripts
SP2007
Get
Scripts
2010/2013
Run SMC
Get PoSh Cmdlets for SharePoint
WWW.SPBIZCONF.COM
Using SharePoint Cmdlets in the ISE
O365:
Import-Module microsoft.online.sharepoint.Powershell
On Prem 2010+:
C:...14 or 15CONFIGPOWERSHELL
RegistrationSharePoint.ps1
2007:
[void][System.Reflection.Assembly]::
LoadWithPartialName("Microsoft.SharePoint")
WWW.SPBIZCONF.COM
Highlights from the SharePoint Object Model
SPField
SPListItem
SPList
SPWeb
SPWebApplication
SPFarm
Online Conference
June 17th and 18th 2015
WWW.SPBIZCONF.COM
On-Prem is simpler
Get-SPSite $url
• Use Farm Account or grant access with Add-SPShellAdmin
Online Conference
June 17th and 18th 2015
SPWeb SPSite
Inline In Script
Online Conference
June 17th and 18th 2015
Online Conference
June 17th and 18th 2015
Chapter 4
WWW.SPBIZCONF.COM
Real World Examples
• Check the Farm Version
• Check Versioning on all document Libraries
• Create List Items
• Export Web App Properties to a file
• Bulk Site Creation
WWW.SPBIZCONF.COM
What’s your Farm Version?
PS C:UsersAdministrator> $(get-
SPFarm).BuildVersion
Major Minor Build Revision
----- ----- ----- --------
14 0 6109 5002
WWW.SPBIZCONF.COM
Get a Web and Explore it!
$web = get-spweb http://server/path
THEN
$web
Online Conference
June 17th and 18th 2015
WWW.SPBIZCONF.COM
Check Doc Lib Versioning Settings
function global:show-all-doclibs ($web)
{$web.Lists | where-object {($_.Hidden -ne
$true) -and ($_.BaseType -eq
"DocumentLibrary")} }
function global:show-all-doclib-versettings
($web)
{show-all-doclibs ($web) |select-object -
property Title, EnableVersioning,
MajorVersionLimit,
EnableMinorVersions,MajorWithMinorVersionsLimi
t,forceCheckout}
$site = get-spsite “http://server/path”
Online Conference
June 17th and 18th 2015
WWW.SPBIZCONF.COM
Practical Uses
• Bulk Create Sites1
• List Item CRUD2
•Create data for test cases3
• Associate Workflows with a List4
•Work across site collections5
• Deployment Scripting6
• Identify files that won’t upload7
WWW.SPBIZCONF.COM
More Practical Uses
• Sync Wep App Properties8
• Install SharePoint9
• Repeatably Manage Content10
• Update Field Definitions11
• Report on Security12
WWW.SPBIZCONF.COM
Create a List Item Server-Side
WWW.SPBIZCONF.COM
Audio Alerts
• Stick this at the end of your long running
script:
$Voice = new-object -com SAPI.SpVoice
$Voice.Speak(“Deployment is done!")
Online Conference
June 17th and 18th 2015
Site Definitions in V. Studio
• Not an answer by themselves
• Define site content
• Intended for reuse
– Mismatch to one time need
• CAML and PITA
• Harder: Making it data driven
• Change Site Def -> Recreate
Site
PowerShell & Excel & UI
• Well suited for one time “blow
in’s”
• Define the site template in the
UI or use standard
• Save as a template
– Even pub sites - sometimes
• PowerShell has easy loops
• Data driven from a CSV
• Changes -> Mod Scripts
WWW.SPBIZCONF.COM
The PowerShell Solution
• Read the list of sites from CSV
• Loop:
– Create Site
– Configure Site
• Turn on Features
• Set Master Pages, Welcome Page
• Hide Libraries, set versioning
• Adjust Navigation
– Add Lists, Libraries, Pages, Web parts, etc
• Loop again & again if needed – iterative!
Online Conference
June 17th and 18th 2015
Chapter 5
Online Conference
June 17th and 18th 2015
Online Conference
June 17th and 18th 2015
Online Conference
June 17th and 18th 2015
Online Conference
June 17th and 18th 2015
WWW.SPBIZCONF.COM
Resources Summary
• Jeff Hicks
• Gary LaPointe
• Raymond Mitchell
• Todd Klindt
• POSHCODE.ORG
• get-spscripts.com
• Michaelblumenthal.me
• SPYam
• PowerShell Product Team
Blog
• TechNet Script Center
• PowerShell in Action by Bruce
Payette
• CodePlex: PSBBs (mine)
• CodePlex:SPInstaller
• Blog.BlumenthalIT.Net
• SharePointJack.com
Online Conference
June 17th and 18th 2015
• It’s Easy to Get Started!1
• Learn the PowerShell Syntax2
• PowerShell + SharePoint3
• Real World Examples4
• More Resources5
WWW.SPBIZCONF.COM
Please fill in my session feedback form available
from the ‘Session Resources’ tab
on my session window.
Why not join us in October at
Michael Blumenthal
Technical Solution Evangelist
PSC Group, LLC
• Contact me at:
• MBlumenthal@psclistens.com
• MichaelBlumenthal.me
• Twitter: @MichaelBL
• Yammer.com/SPYam

More Related Content

PPTX
SharePoint Framework 101 (SPFx)
PPTX
SPSNL16 - Building Office 365 and SharePoint solutions using modern developer...
PPTX
Chris O'Brien - Introduction to the SharePoint Framework for developers
PPTX
Introduction to SharePoint Framework
PPTX
O365: Attack of the Clones
PPTX
Modern SharePoint, the Good, the Bad, and the Ugly
PPTX
Angular.js in XPages
PPT
Bp308 Ibm Lotus Domino Web Facelift Using Ajax And Dxl
SharePoint Framework 101 (SPFx)
SPSNL16 - Building Office 365 and SharePoint solutions using modern developer...
Chris O'Brien - Introduction to the SharePoint Framework for developers
Introduction to SharePoint Framework
O365: Attack of the Clones
Modern SharePoint, the Good, the Bad, and the Ugly
Angular.js in XPages
Bp308 Ibm Lotus Domino Web Facelift Using Ajax And Dxl

What's hot (20)

PDF
Webアプリケーションフレームワークを利用した効率的なカスタムWeb開発
PPTX
Introduction to SharePoint Framework (SPFx)
PDF
All about SPFx
PPTX
TypeScript and SharePoint Framework
PDF
Bring Order to the Chaos: Take the MVC Plunge
PDF
Joomla! multiplied - How to run Multi-Sites - JandBeyond 2014
PPTX
ESPC 2016 - From SharePoint to Office 365 Development - The path to your new ...
PPTX
Overview of SharePoint Framework (SPFx)
PPTX
Supercharge Your SharePoint Framework Webpart with React
PDF
September-2021 OpenNTF Webinar: Domino Online Meeting Integration (DOMI)
PPTX
Build Your First SharePoint Framework Webpart
PPTX
The Adventures of Azure Functions and Microsoft Graph
PPTX
Cotent Deploymet In Share Point 2007
PPTX
Office script labs
PPTX
The Greatest Introduction to SharePoint Framework (SPFx) on earth!
PDF
Engage 2019: Your Data in the Major Leagues: A Practical and Updated Guide to...
PPTX
SharePoint content deployment presentation
PPTX
Share point content deploymet presentation Chicago
PPTX
SharePoint PowerShell for the Admin and Developer - A Venn Diagram Experience
PDF
BPM-4 Migration from jBPM to Activiti
Webアプリケーションフレームワークを利用した効率的なカスタムWeb開発
Introduction to SharePoint Framework (SPFx)
All about SPFx
TypeScript and SharePoint Framework
Bring Order to the Chaos: Take the MVC Plunge
Joomla! multiplied - How to run Multi-Sites - JandBeyond 2014
ESPC 2016 - From SharePoint to Office 365 Development - The path to your new ...
Overview of SharePoint Framework (SPFx)
Supercharge Your SharePoint Framework Webpart with React
September-2021 OpenNTF Webinar: Domino Online Meeting Integration (DOMI)
Build Your First SharePoint Framework Webpart
The Adventures of Azure Functions and Microsoft Graph
Cotent Deploymet In Share Point 2007
Office script labs
The Greatest Introduction to SharePoint Framework (SPFx) on earth!
Engage 2019: Your Data in the Major Leagues: A Practical and Updated Guide to...
SharePoint content deployment presentation
Share point content deploymet presentation Chicago
SharePoint PowerShell for the Admin and Developer - A Venn Diagram Experience
BPM-4 Migration from jBPM to Activiti
Ad

Similar to Introduction to PowerShell for SharePoint Admins and Developers (20)

PPTX
Introduction to PowerShell - Be a PowerShell Hero - SPFest workshop
PPTX
Introduction to PowerShell for SharePoint Admins and Developers - SharePoint ...
PPTX
Introduction to PowerShell for SharePoint - SharePointFest 2014 workshop
PPTX
Intro to SharePoint + PowerShell
PPTX
Automating PowerShell with SharePoint
PPTX
Introduction to windows power shell in sharepoint 2010
PPTX
PowerShell Fundamentals for SharePoint
PPTX
SP24S053 Introduction to PowerShell for SharePoint Developers and Administrators
PPTX
Intro to PowerShell
PDF
Powershell to the People #suguk
PPTX
Power shell for sp admins
PPTX
Making Life Easier with PowerShell (SPSVB 2012)
PPTX
Using PowerShell for SharePoint 2013
PDF
Operacion Guinda 2
PPTX
PowerShell Basics for Office Apps and Servers
PPTX
Making Life Easier with PowerShell - SPSRIC
PPTX
Managing SharePoint Anywhere with Windows PowerShell
PPTX
NZ Code Camp 2011 PowerShell + SharePoint
PPTX
Brian Jackett: Managing SharePoint 2010 Farms with Powershell
PPTX
Brian Jackett: Managing SharePoint 2010 Farms with Powershell
Introduction to PowerShell - Be a PowerShell Hero - SPFest workshop
Introduction to PowerShell for SharePoint Admins and Developers - SharePoint ...
Introduction to PowerShell for SharePoint - SharePointFest 2014 workshop
Intro to SharePoint + PowerShell
Automating PowerShell with SharePoint
Introduction to windows power shell in sharepoint 2010
PowerShell Fundamentals for SharePoint
SP24S053 Introduction to PowerShell for SharePoint Developers and Administrators
Intro to PowerShell
Powershell to the People #suguk
Power shell for sp admins
Making Life Easier with PowerShell (SPSVB 2012)
Using PowerShell for SharePoint 2013
Operacion Guinda 2
PowerShell Basics for Office Apps and Servers
Making Life Easier with PowerShell - SPSRIC
Managing SharePoint Anywhere with Windows PowerShell
NZ Code Camp 2011 PowerShell + SharePoint
Brian Jackett: Managing SharePoint 2010 Farms with Powershell
Brian Jackett: Managing SharePoint 2010 Farms with Powershell
Ad

More from Michael Blumenthal (Microsoft MVP) (20)

PPTX
Teaching Prompting and Prompt Sharing to End Users.pptx
PPTX
What's New in Copilot in YOUR Tenant - Ignite 2024 - THR586.pptx
PPTX
How and Why You Should Manage M365 Message Center in Planner
PPTX
Tracking what's new and next for Teams in Your tenant.pptx
PPTX
Collaboration Fundamentals - ALI Modern Intranets May 2023
PPTX
Hidden Gems of Office - Teams Day Online Sept 2022
PPTX
So You Think You Have OneDrive Deployed.pptx
PPTX
Toastmasters Word of the Day - Feghoot.pptx
PPTX
10 Tips to Make You A Better Speaker.pptx
PPTX
Hidden Gems of Microsoft Office
PPTX
October 2020 Office 365 Adoption Users Group meeting agenda
PPTX
August 2020 Office 365 Adoption Users Group meeting agenda
PPTX
Lessons Learned while Deploying OneDrive Sync
PPTX
2020 July Office 365 AI news for the Midwest AI Group (MAIG)
PPTX
June 2020 Office 365 Adoption User Group meeting agenda
PPTX
May 2020 Office 365 Adoption User Group Meeting Agenda
PPTX
M365 The Tour Israel: Deploying OneDrive Sync
PPTX
April 2020 Office 365 Adoption Users Group meeting agenda
PPTX
Overview of Office 365: The Elephant in the Room
PPTX
Deploying OneDrive Sync
Teaching Prompting and Prompt Sharing to End Users.pptx
What's New in Copilot in YOUR Tenant - Ignite 2024 - THR586.pptx
How and Why You Should Manage M365 Message Center in Planner
Tracking what's new and next for Teams in Your tenant.pptx
Collaboration Fundamentals - ALI Modern Intranets May 2023
Hidden Gems of Office - Teams Day Online Sept 2022
So You Think You Have OneDrive Deployed.pptx
Toastmasters Word of the Day - Feghoot.pptx
10 Tips to Make You A Better Speaker.pptx
Hidden Gems of Microsoft Office
October 2020 Office 365 Adoption Users Group meeting agenda
August 2020 Office 365 Adoption Users Group meeting agenda
Lessons Learned while Deploying OneDrive Sync
2020 July Office 365 AI news for the Midwest AI Group (MAIG)
June 2020 Office 365 Adoption User Group meeting agenda
May 2020 Office 365 Adoption User Group Meeting Agenda
M365 The Tour Israel: Deploying OneDrive Sync
April 2020 Office 365 Adoption Users Group meeting agenda
Overview of Office 365: The Elephant in the Room
Deploying OneDrive Sync

Recently uploaded (20)

PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
cuic standard and advanced reporting.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Machine learning based COVID-19 study performance prediction
PDF
KodekX | Application Modernization Development
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Electronic commerce courselecture one. Pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
NewMind AI Weekly Chronicles - August'25 Week I
Encapsulation_ Review paper, used for researhc scholars
20250228 LYD VKU AI Blended-Learning.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Network Security Unit 5.pdf for BCA BBA.
Per capita expenditure prediction using model stacking based on satellite ima...
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
cuic standard and advanced reporting.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
The Rise and Fall of 3GPP – Time for a Sabbatical?
“AI and Expert System Decision Support & Business Intelligence Systems”
Review of recent advances in non-invasive hemoglobin estimation
Machine learning based COVID-19 study performance prediction
KodekX | Application Modernization Development
Mobile App Security Testing_ A Comprehensive Guide.pdf
Electronic commerce courselecture one. Pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Understanding_Digital_Forensics_Presentation.pptx
Unlocking AI with Model Context Protocol (MCP)
NewMind AI Weekly Chronicles - August'25 Week I

Introduction to PowerShell for SharePoint Admins and Developers

Editor's Notes

  • #4: Every SharePoint Developer needs this! Fast and Flexible Great for Last Mile Problems. The MSFT standard for Scripting.
  • #5: Who would like another tool in their toolbox, one that will help them with SharePoint, but also with many other things? How about the swiss army knife of tools? It will make you a better developer or administrator!
  • #7: Who here already has installed and PowerShell? Who’s using Server 2003? 2008? Win 2008 – It’s an OS Feature – “servermanagercmd –install PowerShell”
  • #12: One is SharePoint aware, the other isn’t!
  • #16: begin with a $ Name that Language… Similar to @variables in SQL, apparently also Ruby, PHP. Arrays start at 0
  • #18: Mention Aliases
  • #20: Get-Member examples
  • #22: Can you imagine trying to do this in unix or vbscript?
  • #25: Get-Help about_flow_control Mention that collections start at 0
  • #35: Your mother doesn’t work here! You must clean up after yourself.
  • #36: http://sharepoint.microsoft.com/blog/Pages/BlogPost.aspx?PageType=4&ListId={72C1C85B-1D2D-4A4A-90DE-CA74A7808184}&pID=524 http://msdn.microsoft.com/en-us/library/ee557362.aspx See Assignment collections - http://technet.microsoft.com/en-us/library/ff607664.aspx
  • #49: Once used a choice column’s values instead of a CSV
  • #51: Windows PowerShell in Action by Bruce Payette, V2 Since then Hicks and Jones have written some good books too
  • #53: http://www.codeplex.com/psbb
  • #55: Also: PoshCode.Org TechNet Script Center http://www.microsoft.com/technet/scriptcenter/default.mspx MSDN SharePoint Developer Center http://msdn.microsoft.com/en-us/office/aa905503.aspx Zach Rosenfield’s Blog - http://sharepoint.microsoft.com/blogs/zach/default.aspx http://blog.falchionconsulting.com/ http://thepowershellguy.com/blogs/posh/pages/powertab.aspx
  • #56: Who would like another tool in their toolbox, one that will help them with SharePoint, but also with many other things? How about the swiss army knife of tools? It will make you a better developer or administrator!