Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202
1. SIA 202
Tools and Best Practices
When PowerShell Scripting for
SharePoint
Michael Blumenthal
PSC Group, LLC
Mblumenthal@PSCListens.com
2. 2
Who is Michael Blumenthal?
Sr. Solution Architect
at PSC Group
CSPUG Co-Leader
INETA Champ 2010-2012
19 years in IT Consulting
10 years working with
SharePoint (2003,2007,2010, 2013)
3. 3
This is about you
Version of SharePoint?
Admin, Developer, Both, Other?
PowerShell experience?
SharePoint experience?
Unix experience?
Scripting experience?
18. 18
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?
36. 36
Best Practices
⢠Write your scripts as functions
that announce themselves1
⢠Comment Your Functions2
⢠Follow the Verb-Noun pattern3
â˘Use Source Control4
38. 38
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.
#>
39. 39
Use an Action-Thing Function Name
Add
Backup
Clear
Connect
Convert
Copy
Disable
Disconnect
Dismount
Enable
EtcâŚ
SPAppDeniedEndpoint
SPClaimTypeMapping
SPDiagnosticsPerformanceCo
unter
SPDistributedCacheServiceIns
tance
SPEduClassMember
SPEduUser
SPInfoPathUserAgent
SPPluggableSecurityTrimmer
SPProfileLeader
SPProfileSyncConnection
EtcâŚ
42 verbs combined with 347 nouns to give us 799 cmdlets
45. 45
More Good Ideas
Always read scripts before running them
Make yours safe when others donât
Check for valid parameter values
get-help about_Functions_Advanced_Parameters
Do error handling
get-help about_Try_Catch_Finally
get-help about_CommonParameters
-ErrorAction and -ErrorVariable
Dispose of SPWebs and SPSites
55. 55
Resources Summary
MSFT
Reverse Engineering SharePoint Pages
Bruce Payetteâs Book v2
PowerShell Product Team Blog
Community
CodePlex: PSBBs (mine), CodePlex:SPInstaller
My Blog at BlumenthalIT.Net
Jeff Hicks , Gary LaPointe, Raymond Mitchell,
Todd Klindt, SharePoint Jack
POSHCODE.ORG, ScriptCenter, get-
spscripts.com
56. 56
Improve your POSH Scripts.
Your future self will thank you.
Itâs Easy to Get
Started!
Learn & Use the
PowerShell Syntax
More Resources
In ReviewâŚ
57. 57
Questions
& Raffle
⢠Michael Blumenthal
SharePoint Architect
PSC Group, LLC
⢠MBlumenthal@psclistens.com
⢠psclistens.com
⢠www.cspug.org
⢠Twitter: @MichaelBL
⢠SPYam
Thank you for your time today.