Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202
-
Upload
michael-blumenthal -
Category
Technology
-
view
285 -
download
1
description
Transcript of Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202
![Page 1: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/1.jpg)
SIA 202Tools and Best Practices
When PowerShell Scripting for SharePoint
Michael BlumenthalPSC Group, LLC
![Page 2: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/2.jpg)
2
Who is Michael Blumenthal?
Sr. Solution Architectat PSC Group
CSPUG Co-LeaderINETA Champ 2010-201219 years in IT Consulting10 years working with
SharePoint (2003,2007,2010, 2013)
![Page 3: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/3.jpg)
3
This is about you
Version of SharePoint?Admin, Developer, Both, Other?PowerShell experience?SharePoint experience?Unix experience?Scripting experience?
![Page 4: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/4.jpg)
4
Agenda
• Tools 1• One Trick2• Best Practices3• Resources4
![Page 5: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/5.jpg)
5
Chapter 1
TOOLS
![Page 6: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/6.jpg)
ToolsISE• Add Windows Feature
PowerShell Plus - Idera• SP2010 focused
PowerGui• Pro version Too
PowerShell Studio - Sapien• Not Free
Visual Studio 2012
![Page 7: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/7.jpg)
7
ISE, ISE Baby
Microsoft’s
Available Since POSH V2• SP2010 -> POSH 2; SP2013 -> POSH 3
OS Feature
![Page 8: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/8.jpg)
8
You might have to add the ISE
![Page 9: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/9.jpg)
9
V1
![Page 10: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/10.jpg)
10
V2Use With SP2010
![Page 11: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/11.jpg)
11
PowerShell V3 ISE - for SP2013
![Page 12: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/12.jpg)
12
POSH vs the SharePoint Mgmt Shell
POSH + SnapIn = SharePoint Management Shell
![Page 13: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/13.jpg)
13
Where is it?
![Page 14: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/14.jpg)
14
![Page 15: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/15.jpg)
15
PowerGUI
Created for POSH v1 originally
Free & large community support
Lots of Add-ons• SCCS in Pro
![Page 16: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/16.jpg)
16
![Page 17: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/17.jpg)
17
PowerGUI screen shot
![Page 18: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/18.jpg)
18
Idera’s PowerShell Plus
Free with ads for Idera’s other productsIncludes support for SP2010, but not 2013
Framework Dependecy….Lots of features…. Bloated Overkill?
![Page 19: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/19.jpg)
19
![Page 20: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/20.jpg)
20
Sapien’s PowerShell Studio
Trial requires special trial license in a VMDoes create a POSH Library
![Page 21: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/21.jpg)
21
![Page 22: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/22.jpg)
22
Sapien Bonus
![Page 23: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/23.jpg)
23
Visual Studio 2012 Integration with TFSFor SharePoint developers, tool of choiceAdd-ons available
![Page 24: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/24.jpg)
24
![Page 25: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/25.jpg)
25
![Page 26: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/26.jpg)
26
![Page 27: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/27.jpg)
27
Conclusion on POSH IDEs
![Page 28: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/28.jpg)
One TrickDecompiling a SharePoint Page
![Page 29: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/29.jpg)
29
Use a Decompiler to see MSFT’s Code!
ILSpy.net
dotPeek (jetbrains)
justDecompile (Telerik)
.Net Reflector(RedGate)
Others…
![Page 30: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/30.jpg)
30
![Page 31: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/31.jpg)
31
![Page 32: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/32.jpg)
32
![Page 33: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/33.jpg)
33
![Page 34: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/34.jpg)
34
![Page 35: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/35.jpg)
35
Chapter 3
BEST PRACTICES
![Page 36: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/36.jpg)
36
Best Practices
• Write your scripts as functions that announce themselves1
• Comment Your Functions2• Follow the Verb-Noun pattern3•Use Source Control4
![Page 37: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/37.jpg)
37
Self Announcing Functions
…
![Page 38: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/38.jpg)
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.
#>
![Page 39: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/39.jpg)
39
Use an Action-Thing Function Name
Add Backup Clear Connect Convert Copy Disable Disconnect Dismount Enable
Etc…
SPAppDeniedEndpoint SPClaimTypeMapping SPDiagnosticsPerformanceCounter SPDistributedCacheServiceInstance SPEduClassMember SPEduUser SPInfoPathUserAgent SPPluggableSecurityTrimmer SPProfileLeader SPProfileSyncConnection
Etc…
42 verbs combined with 347 nouns to give us 799 cmdlets
![Page 40: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/40.jpg)
40
![Page 41: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/41.jpg)
41
Find custom commands this way
Refresh the command list
Actions you can take once you fill in parameters
![Page 42: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/42.jpg)
42
TFS for Source Code Control
![Page 43: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/43.jpg)
43
Compare versions
![Page 44: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/44.jpg)
44
Compare Versions – the Diff
![Page 45: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/45.jpg)
45
More Good Ideas
Always read scripts before running themMake yours safe when others don’tCheck 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
![Page 46: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/46.jpg)
46
Chapter 4
MORE RESOURCES
![Page 48: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/48.jpg)
48
![Page 49: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/49.jpg)
49
![Page 50: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/50.jpg)
50
![Page 51: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/51.jpg)
51
![Page 52: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/52.jpg)
52
![Page 53: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/53.jpg)
53
![Page 54: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/54.jpg)
54
JEFF HICKS
![Page 55: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/55.jpg)
55
Resources SummaryMSFT
Reverse Engineering SharePoint PagesBruce Payette’s Book v2PowerShell Product Team Blog
CommunityCodePlex: PSBBs (mine), CodePlex:SPInstaller My Blog at BlumenthalIT.NetJeff Hicks , Gary LaPointe, Raymond Mitchell, Todd Klindt, SharePoint JackPOSHCODE.ORG, ScriptCenter, get-spscripts.com
![Page 56: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/56.jpg)
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…
![Page 57: Best practices and tools for PowerShell and SharePoint Scripting SharePointFest SIA202](https://reader031.fdocuments.us/reader031/viewer/2022013003/545ca11bb0af9fb32c8b4a2f/html5/thumbnails/57.jpg)
57
Questions& Raffle
• Michael BlumenthalSharePoint ArchitectPSC Group, LLC
• [email protected]• psclistens.com• www.cspug.org• Twitter: @MichaelBL• SPYam
Thank you for your time today.