860 likes | 1.02k 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 8 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 • 8 years working with SharePoint • MCITP: SharePoint 2010; MCTS: WSS Dev • MCTS: MOSS Config & MCTS: WSS Config • MCAD, MCSE, MCDBA, CAPM
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 = New-Object Microsoft.SharePoint.SPSite(“http://server/path”) OR $site = Get-SPSite(“http://server/path”) THEN $site
A Word About Memory Management Dispose
Chapter 3 Real World Examples
Real World Examples • Check the Version • Check Versioning on all document Libraries • Clear a list • Look at multiple Event Throttling levels at once for the ULS (diagnostic) log
What’s your MOSS Version? $farm = [Microsoft.SharePoint.Administration.SPFarm]::Local $farm.BuildVersion Major Minor Build Revision ----- ----- ----- -------- 12 0 0 6318
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!
Look at the ULS configuration • Why? • See multiple event categories at once! • How? • $ulsid = $farm.Services | select-object TypeName, Id | where {$_.TypeName -eq "Windows SharePoint Diagnostics Service"} | Select-Object Id • $ulsvc = $farm.GetObject($ulsid.Id.ToString()) • $ulsvc.GetItems() | Select-Object Name, EventSeverity, TraceSeverity, hidden | where {$_.hidden -eq 0}
Chapter 4 More Resources
Use a Decompiler to see MSFT’s Code! OR ILSpy.net dotPeek (jetbrains) justDecompile (Telerik) Others… No Longer Free