SIA 202
Tools and Best Practices
When PowerShell Scripting for
SharePoint
Michael Blumenthal
PSC Group, LLC
Mblumenthal@PS...
2
Who is Michael Blumenthal?
Sr. Solution Architect
at PSC Group
CSPUG Co-Leader
INETA Champ 2010-2012
19 years in IT Cons...
3
This is about you
Version of SharePoint?
Admin, Developer, Both, Other?
PowerShell experience?
SharePoint experience?
Un...
4
Agenda
•Tools1
•One Trick2
•Best Practices3
•Resources4
5
Chapter 1
Tools
ISE
•Add Windows Feature
PowerShell Plus - Idera
•SP2010 focused
PowerGui
•Pro version Too
PowerShell Studio - Sapie...
7
ISE, ISE Baby
Microsoft’s
Available Since POSH V2
• SP2010 -> POSH 2; SP2013 -> POSH 3
OS Feature
8
You might have to add the ISE
9
10
11
PowerShell V3 ISE - for SP2013
12
POSH vs the SharePoint Mgmt Shell
POSH + SnapIn = SharePoint Management Shell
13
Where is it?
14
15
PowerGUI
Created for POSH v1
originally
Free & large community
support
Lots of Add-ons
• SCCS in Pro
16
17
PowerGUI screen shot
18
Idera’s PowerShell Plus
Free with ads for Idera’s other products
Includes support for SP2010, but not 2013
Framework De...
19
20
Sapien’s PowerShell Studio
Trial requires special trial license in a VM
Does create a POSH Library
21
22
Sapien Bonus
23
Visual Studio 2012
Integration with TFS
For SharePoint developers, tool of choice
Add-ons available
24
25
26
27
Conclusion on POSH IDEs
One Trick
Decompiling a SharePoint Page
29
Use a Decompiler to see MSFT’s
Code!
ILSpy.net
dotPeek (jetbrains)
justDecompile (Telerik)
.Net Reflector(RedGate)
Othe...
30
31
32
33
34
35
Chapter 3
36
Best Practices
• Write your scripts as functions
that announce themselves1
• Comment Your Functions2
• Follow the Verb-...
37
Self Announcing Functions
…
38
Comment your functions
<#
.SYNOPSIS –a brief explanation of what the script or function does.
.DESCRIPTION – a more det...
39
Use an Action-Thing Function Name
Add
Backup
Clear
Connect
Convert
Copy
Disable
Disconnect
Dismount
Enable
Etc…
SPAppDe...
40
41
Find custom commands this way
Refresh the command list
Actions you can take once
you fill in parameters
42
TFS for Source Code Control
43
Compare versions
44
Compare Versions – the Diff
45
More Good Ideas
Always read scripts before running them
Make yours safe when others don’t
Check for valid parameter val...
46
Chapter 4
47
48
49
50
51
52
53
54
55
Resources Summary
MSFT
Reverse Engineering SharePoint Pages
Bruce Payette’s Book v2
PowerShell Product Team Blog
Commun...
56
Improve your POSH Scripts.
Your future self will thank you.
It’s Easy to Get
Started!
Learn & Use the
PowerShell Syntax...
57
Questions
& Raffle
• Michael Blumenthal
SharePoint Architect
PSC Group, LLC
• MBlumenthal@psclistens.com
• psclistens.c...
Upcoming SlideShare
Loading in …5
×

Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202

969 views

Published on

Best practices for using PowerShell scripting with SharePoint 2013, SharePoint 2010, and MOSS 2007.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
969
On SlideShare
0
From Embeds
0
Number of Embeds
129
Actions
Shares
0
Downloads
17
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202

  1. 1. SIA 202 Tools and Best Practices When PowerShell Scripting for SharePoint Michael Blumenthal PSC Group, LLC Mblumenthal@PSCListens.com
  2. 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. 3 This is about you Version of SharePoint? Admin, Developer, Both, Other? PowerShell experience? SharePoint experience? Unix experience? Scripting experience?
  4. 4. 4 Agenda •Tools1 •One Trick2 •Best Practices3 •Resources4
  5. 5. 5 Chapter 1
  6. 6. Tools ISE •Add Windows Feature PowerShell Plus - Idera •SP2010 focused PowerGui •Pro version Too PowerShell Studio - Sapien •Not Free Visual Studio 2012
  7. 7. 7 ISE, ISE Baby Microsoft’s Available Since POSH V2 • SP2010 -> POSH 2; SP2013 -> POSH 3 OS Feature
  8. 8. 8 You might have to add the ISE
  9. 9. 9
  10. 10. 10
  11. 11. 11 PowerShell V3 ISE - for SP2013
  12. 12. 12 POSH vs the SharePoint Mgmt Shell POSH + SnapIn = SharePoint Management Shell
  13. 13. 13 Where is it?
  14. 14. 14
  15. 15. 15 PowerGUI Created for POSH v1 originally Free & large community support Lots of Add-ons • SCCS in Pro
  16. 16. 16
  17. 17. 17 PowerGUI screen shot
  18. 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?
  19. 19. 19
  20. 20. 20 Sapien’s PowerShell Studio Trial requires special trial license in a VM Does create a POSH Library
  21. 21. 21
  22. 22. 22 Sapien Bonus
  23. 23. 23 Visual Studio 2012 Integration with TFS For SharePoint developers, tool of choice Add-ons available
  24. 24. 24
  25. 25. 25
  26. 26. 26
  27. 27. 27 Conclusion on POSH IDEs
  28. 28. One Trick Decompiling a SharePoint Page
  29. 29. 29 Use a Decompiler to see MSFT’s Code! ILSpy.net dotPeek (jetbrains) justDecompile (Telerik) .Net Reflector(RedGate) Others…
  30. 30. 30
  31. 31. 31
  32. 32. 32
  33. 33. 33
  34. 34. 34
  35. 35. 35 Chapter 3
  36. 36. 36 Best Practices • Write your scripts as functions that announce themselves1 • Comment Your Functions2 • Follow the Verb-Noun pattern3 •Use Source Control4
  37. 37. 37 Self Announcing Functions …
  38. 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. 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
  40. 40. 40
  41. 41. 41 Find custom commands this way Refresh the command list Actions you can take once you fill in parameters
  42. 42. 42 TFS for Source Code Control
  43. 43. 43 Compare versions
  44. 44. 44 Compare Versions – the Diff
  45. 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
  46. 46. 46 Chapter 4
  47. 47. 47
  48. 48. 48
  49. 49. 49
  50. 50. 50
  51. 51. 51
  52. 52. 52
  53. 53. 53
  54. 54. 54
  55. 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. 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. 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.

×