590 likes | 723 Views
PowerShell for SharePoint Developers and Administrators . Michael Blumenthal Magenic Technologies MichaelBl@Magenic.com. Who is Michael Blumenthal?. Sr. Consultant @ Magenic (MSFT Gold Partner) 16+ years in IT Consulting 9 years working with SharePoint
E N D
PowerShell for SharePoint Developers and Administrators Michael Blumenthal Magenic Technologies MichaelBl@Magenic.com
Who is Michael Blumenthal? • Sr. Consultant @ Magenic (MSFT Gold Partner) • 16+ years in IT Consulting • 9 years working with SharePoint • MCITP: SharePoint 2010; MCTS: WSS Dev • MCTS: MOSS Config & MCTS: WSS Config • MCAD, MCSE, MCDBA, CAPM, INETA Champ
Chapter 1 It’s Easy to get Started!
Chapter 2 Learn the PowerShell Syntax!
Punctuation Pronunciation Is “$#|” a “one dollar hash pipe”?
1 Variables begin with a $
The Power of Piping! • 3 |
Where-Object • 6
Loading SharePoint DLLs [void][System.Reflection.Assembly]:: LoadWithPartialName("Microsoft.SharePoint")
Get a Site and Explore it! $site = get-spsite http://server/path THEN $site
A Word About Memory Management Dispose
Chapter 3 Real World Examples
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
What’s your SP2010 Version? PS C:\Users\Administrator> $(get-SPFarm).BuildVersion Major Minor Build Revision ----- ----- ----- -------- 14 0 6109 5002
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,MajorWithMinorVersionsLimit,forceCheckout} $site = get-spsite “http://server/path” show-all-doclib-versettings $site.RootWeb
Clear a List • Make a mess: • Clean it up!
Bulk Site Creation Site Definitions in V. Studio 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 PowerShell has easy loops Data driven from a CSV Changes -> Mod Scripts • 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
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!
Chapter 4 More Resources
Use a Decompiler to see MSFT’s Code! OR ILSpy.net dotPeek (jetbrains) justDecompile (Telerik) Reflector(RedGate) Others… No Longer Free