The slides from Michael Blumenthal's and Jack Fruh's "Be a Hero with PowerShell" workshop at SharePoint fest, a comprehensive introduction to using PowerShell with SharePoint.
2. 2
Who is Michael Blumenthal?
Sr. Solution Architect
at PSC Group
CSPUG Co-Leader
INETA Champ 2010-2013
18 years in IT Consulting
10 years working with
SharePoint (2003,2007,2010, 2013)
3. 3
Who is Jack Fruh?
SharePoint Administrator
Fortune 500 Company
Big on community
SPS Chicago Suburbs Co-
Leader
SharePointJack.com
SPYam
SharePoint-Community.org
4. 4
This is about you
Version of SharePoint?
Admin, Developer, Both, Other?
PowerShell experience?
SharePoint experience?
6. 6
PowerShell puts the SharePoint
Engine at your fingertips!
• It’s Easy to Get Started!1
• Learn the PowerShell Syntax2
• Real World Examples3
• More Resources4
• Demo!5
24. Making Comparisons4
Operator Meaning Operator Meaning
-eq Equals -le Less Than or
Equal To
-ne Not Equals -like Wildcard Match
-gt Greater Than -notlike Not (Wildcard
Match)
-ge Greater Than
or Equal To
-match Reg. Exp. Match
-lt Less Than -notmatch Not (Reg. Exp.
Match)
41. 41
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
42. 42
More Practical Uses
• Sync Wep App Properties8
• Install SharePoint9
• Repeatably Manage Content10
• Update Field Definitions11
• Edit MP3 Metadata, Make Flashcards12
43. 43
Real World Examples
Check the Farm Version
Create List Items
Bulk Site Creation
Post Deployment Build Scripts with Audio Alerts
Document Versioning Settings (later)
44. 44
What’s your SharePoint Version?
PS C:UsersAdministrator> $(get-
SPFarm).BuildVersion
Major Minor Build Revision
----- ----- ----- --------
14 0 6109 5002
70. 70
Idera’s PowerShell Plus
Free with ads for Idera’s other products
Includes support for SP2010, but not 2013
Framework Dependecy….
Lots of features…. Bloated Overkill?
77. 77
Best Practices
• Follow the Verb-Noun pattern1
• Comment Your Functions2
• Write your scripts as functions that
announce themselves
•Make accidentals runs harmless
3
• Use Source Control4
79. 79
Comment your functions
<#
.SYNOPSIS –a brief explanation of what the script or function does.
.DESCRIPTION – a more detailed explanation of what the script or function
does.
.PARAMETER name – an explanation of a specific parameter. Replace name
with the parameter name. You can have one of these sections for each
parameter the script or function uses.
.EXAMPLE – an example of how to use the script or function. You can have
multiple .EXAMPLE sections if you want to provide more than one example.
.NOTES – any miscellaneous notes on using the script or function.
.LINK – a cross-reference to another help topic; you can have more than one
of these. If you include a URL beginning with http:// or https://, the shell will
open that URL when the Help command’s –online parameter is used.
#>
81. 81
Find custom commands this way
Refresh the command list
Actions you can take once
you fill in parameters
82. 82
More Good Ideas
Always read scripts before running them
Make it safe for others to not read them first
Write scripts as functions most of the time
Check for valid parameter values
Do error handling
86. 86
Now for More Examples
Jack’s take on Doc Lib Versioning – reporting &
setting
Bulk Site Creation
Email
Logging
SSL Cert Expiration Warning
Deploy WSPs
88. 88
Bulk Site Creation
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
89. 89
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!
102. 102
Resources Summary
MSFT
PowerShell Product Team Blog
Script Center
Community
Various Books
CodePlex: PSBBs (mine), CodePlex:SPInstaller
Blog.BlumenthalIT.Net
SharePointJack.com
Jeff Hicks , Gary LaPointe, Raymond
Mitchell, Todd Klindt, POSHCODE.ORG, get-
spscripts.com
SPYam
104. 104
Questions & Thank You
• Michael Blumenthal
SharePoint Architect
PSC Group, LLC
• MBlumenthal@psclist
ens.com
• psclistens.com
• www.cspug.org
• Twitter:
@MichaelBL
• SPYam
• Jack Fruh
SharePoint Admin
• Jack@SharepointJack.
com
• SPSChicagoSuburbs.com
• SharePointJack.com
• Twitter:
@SharePointJack
• SPYam
Thank you for your time today.
Editor's Notes
Anyone here not done SharePoint development?What kind of development have you done?Who has worked with PowerShell already? Used for what? Your name?Who has worked with other scripting languages?
Every SharePoint Developer needs this!Fast and FlexibleGreat for LastMile Problems. New MSFT std for Scripting
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!
Who here already has installed and PowerShell? Who’s using Server 2003? 2008?Win 2003: http://www.microsoft.com/windowsserver2003/technologies/management/powershell/download.mspxWin 2008 – It’s an OS Feature – “servermanagercmd –install PowerShell”V3 is here
One is SharePoint aware, the other isn’t!
Does anyone have any other names for these?Victor Borge has his own take on these: http://www.youtube.com/watch?v=lF4qii8S3gw
Name that Language…Similar to @variables in SQL, apparently also Ruby, PHP.Arrays start at 0
Mention Aliases
Ask if anyone has unix scripting experience, and what they think of this.Can you imagine trying to do this in unix or vbscript?
Get-Help about_flow_controlMention that collections start at 0
Ask if anyone has unix scripting experience, and what they think of this.Can you imagine trying to do this in unix or vbscript?
If you are familiar with these objects, raise your hand.
Your mother doesn’t work here! You must clean up after yourself.
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!
Who here already has installed and PowerShell? Who’s using Server 2003? 2008?Win 2003: http://www.microsoft.com/windowsserver2003/technologies/management/powershell/download.mspxWin 2008 – It’s an OS Feature – “servermanagercmd –install PowerShell”V3 is here
Also:PoshCode.OrgTechNet 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.aspxhttp://blog.falchionconsulting.com/http://www.powergui.org/downloads.jspahttp://thepowershellguy.com/blogs/posh/pages/powertab.aspx
You owe it to yourself to try out PowerShell.It will make you a better developer!