52
Local Touch—Global Reach Brian T. Jackett Sogeti USA www.BrianTJackett.com @BrianTJackett [email protected] Managing SharePoint 2010 Farms With PowerShell

Brian Jackett: Managing SharePoint 2010 Farms with Powershell

Embed Size (px)

Citation preview

PowerPoint Template--Sogeti USA

Brian T. JackettSogeti [email protected]@us.sogeti.comManaging SharePoint 2010Farms With PowerShellLocal TouchGlobal Reach12010-08-02About Me

Senior Consultant at Sogeti USAMicrosoft BI and Collaboration LeadBloggerTwittererPowerShell EnthusiastCentral Ohio SPUG Steering Committee Frog loverTwitter hashtag: #SPSNYCNo naps scheduled after lunch, wha?

Twitter hashtag: #SPSNYCExplain ICanHasCheeseburger.com and photos32010-08-02AgendaIntroduction to PowerShellBasic UsageDemosIntegrate with SharePointMore DemosHave some funTwitter hashtag: #SPSNYCHalf presentation, half demos. Start out introduction to PowerShell, then get into SharePoint integration. Lots of slides, but move quickly through them.42010-08-02Why Are You In This Talk?Completely new to SharePoint administration

Been using STSADM and need to learn PowerShell

Been using PowerShell and want to use on SharePoint

Little bit of content for everyoneTwitter hashtag: #SPSNYCProbably can align with 1 of these 3 categories. Try to cover content for everyone but focusing on the 100 level introductory content.52010-08-02Quick PollsIs your role admin / developer / other?

Have you used STSADM?

Have you used PowerShell?If yes, level of proficiency (low, medium, high)?

Already working with SharePoint 2010?Twitter hashtag: #SPSNYCGoals for this presentationLearn the following mantraIf you have to write/click twice then script/automate itBasics of PowerShell (independent of SharePoint)Basic overview of SharePoint 2010 commandlets

Twitter hashtag: #SPSNYCThis is how Im rating myself, hopefully these satisfy your goals as well

Quote adapted from Jeremiah Peschka, database application developer in Columbus, OH. Not sure if he borrowed from anyone.

Will cover what a commandlet is later in presentation

72010-08-02My Assistants for the Afternoon

Twitter hashtag: #SPSNYCMost stage performers and magicians have an assistant, so I have mine as well82010-08-02Breaking Open PowerShell

Twitter hashtag: #SPSNYCPowerShell OriginsIntroduced in 2006Originally codename MonadLater renamed to Microsoft Shell (MSH)Later renamed again to Windows PowerShellBecoming a cornerstone tool for administrationExchange 2007SQL Server 2008 and now SharePoint 2010!!

In 2010, your newest Swiss Army Knife in SP tool bagTwitter hashtag: #SPSNYCWhat Is PowerShell?PowerShell isA command line shellObject orientedAble to support .Net objects, not just textExtensibleNew scripting language

Aims to be familiar to those writing VBscript or shell scripting like Unix, but simplified like command lineTwitter hashtag: #SPSNYC112010-08-02Screenshot Comparison to CMD

Twitter hashtag: #SPSNYCQuick view of what PowerShell looks like. On left is a shot of my customized console screen after profile commands have run. Explain more later, but lets me know if certain things are in place.122010-08-02Brief Features OverviewConsistent syntaxShame on STSADMObject oriented pipelineAble to pass object output from one cmdlet as input to nextEx. Get-ChildItem | Sort-Object -Property LastWriteTimeBuilt-in providersTalk to Active Directory, registry, WMI, etc. nativelyAliasesBridge the gap for Unix, VBScript, etc. usersTab completeMany moreTwitter hashtag: #SPSNYCSystem RequirementsDefault installed on Windows 7 and Server 2008 R2Integrated Scripting Environment (ISE) optional role on Server 2008 R2PowerShell V2.Net 2.0 SP 1XP w/ SP 3.0Vista w/ SP1 or SP2Windows Server 2003 w/ SP 2Windows Server 2008 w/ SP 2Windows Server 2008 R2WinRM 2.0 (for additional features)Twitter hashtag: #SPSNYCHow To UseSyntaxVerb-Noun parameter Parameter valueEx. Set-Location Path C:/Variables$variable_name = commandCase insensitivehttp://www.youtube.com/watch?v=KyLqUf4cdwcTwitter hashtag: #SPSNYCHow To UseCommandlets (or cmdlets)Premade commands to handle basic functionalityEx. Get-Help; Invoke-Item; Write-Host400+ with V2Modules and snap-ins allow adding custom commandlets

Scripts (.ps1)Place commands into a script file for repeat useTwitter hashtag: #SPSNYCHow To Find HelpSyntaxGet-Help [cmdlet [*]]Get-Alias [cmdlet [*]](object) | Get-MemberWell get to the pipe operator | later

[] = optional() = object or variableTwitter hashtag: #SPSNYCWhen to UseUse PowerShell whena process must be consistenta process must be performed for multiple workstations/users/etcyou dont know the target that needs to be modified

If you have to write it twice, script itTwitter hashtag: #SPSNYCSecurity ConsiderationsBy default, PowerShell is locked down to not run scriptsNeed to unlock with Set-ExecutionPolicy 6 levels of execution availableGet-Help about_execution_policies

SharePoint requires permissions to run PowerShellAdd-SPShellAdminhttp://technet.microsoft.com/en-us/library/ee748614(office.14).aspx Twitter hashtag: #SPSNYCA Word about the ProfilePowerShell ProfileCan pre-load aliases, shortcuts, variables, etc.Good place to load needed assembliesAccessed at $profile\WindowsPowerShell\Microsoft.PowerShell_profile\WindowsPowerShell\Microsoft.PowerShellise_profileEasy to create: new-item type file path Twitter hashtag: #SPSNYCEnough Intro, Lets Demo

Twitter hashtag: #SPSNYCDemo 1Get-Help

Get-Member

Simple commands with file system

Get-Alias

Tab completeTwitter hashtag: #SPSNYCPower of the Pipe

Twitter hashtag: #SPSNYCPower of the PipeThe Pipe Operator |Output from one command becomes input for the nextString together multiple commands

Filtering OptionSort-ObjectWhere-ObjectSelect-ObjectTwitter hashtag: #SPSNYCDemo 2Piping commands to each other

Sort

Select

WhereTwitter hashtag: #SPSNYCOur Protg is Walking

Twitter hashtag: #SPSNYCPowerShell ProvidersAble to natively talk to:File SystemEnvironmentRegistryAliasFunctionVariableCertificate

Get-PSProvider & Get-PSDriveTwitter hashtag: #SPSNYCI know what youre thinking

28 Slides and no demos about SharePoint yet?!?Twitter hashtag: #SPSNYCAccessing the SharePoint APIMicrosoft.SharePoint.dllSharePoint Object Model HierarchySPFarmSPWebApplicationSPSiteSPWebSPListSPListItemKnow how to handle SPSite and SPWeb memoryStart-SPAssignment globalStop-SPAssignmentTwitter hashtag: #SPSNYCFinally PowerShell + SharePoint

Twitter hashtag: #SPSNYCDemo 3 Site HierarchyAccess SharePoint Hierarchy

Access object properties

http://sharepoint.microsoft.com/blogs/zach/Lists/Posts/Post.aspx?ID=43

Twitter hashtag: #SPSNYCSharePoint BackupScript out a backup/restore procedure (STSADM)Remove old backupsDetermine size of largest backup

Schedule PowerShell commandsPowerShell -command "& 'MyScript.ps1' Place into a .cmd or .bat and schedule as usualCan programmatically call script based on output from othersTwitter hashtag: #SPSNYCSharePoint BackupScript out a backup/restore procedureRemove old backupsDetermine size of largest backup

Twitter hashtag: #SPSNYCScheduling PowerShell ScriptsSchedule PowerShell commandsPowerShell -command "& 'MyScript.ps1' Place into a .cmd or .bat and schedule as usualCan programmatically call script based on output from othersTwitter hashtag: #SPSNYCDemo 4 - BackupsBackup-SPSite

Backup-SPFarm

Get-SPBackupHistoryTwitter hashtag: #SPSNYCShow that Central Admin is aware when you run new PowerShell backups, go to restore page.352010-08-02SharePoint Site AdministrationIdeas to think about:Activate/deactivate featuresSet/unset master pagesCreate/delete siteCheck file sizes on siteUpdate list valuessky is the limitTwitter hashtag: #SPSNYCDemo 5 Interacting SitesCreate site

Delete site

Recursively traverse site hierarchy

Enumerate site templates

Twitter hashtag: #SPSNYCLimit Server Results With Filter SwitchTypically you have this scenarioTwitter hashtag: #SPSNYCLimit Server Results With Filter SwitchUsing Filter limits results coming back from serverTwitter hashtag: #SPSNYCDemo 6 Server Side FilterFilter SPWebs server sideTwitter hashtag: #SPSNYCSee How Fast This Shell Can Go

Twitter hashtag: #SPSNYCComplex ScriptsMultitask within one scriptReference siteRecursively traverse site hierarchyRead SharePoint group membershipDetermine Active Directory groupsExpand Active Directory groups to usersTwitter hashtag: #SPSNYCDemo 7 Johnny 5 is AliveThe laser show spectacularTwitter hashtag: #SPSNYCWhos Brain is Full Now?

Twitter hashtag: #SPSNYCNew Features in V2PowerShell V2PowerShell remotingIntegrated Scripting Environment (ISE)Script debugging (breakpoints)Background jobsModulesGet-Help online

Twitter hashtag: #SPSNYC452010-08-02V2 Release ScheduleShips with Windows 7 and Server 2008 R2Automatically installed by defaultDownloadable for XP/Server 2003 and aboveReleased end of Oct 2009 as Windows Management FrameworkTwitter hashtag: #SPSNYCSharePoint 2010 ConsiderationsPowerShell preferred command line tool over STSADMSTSADM is being depricatedMeans STSADM is supported, but start learning PowerShellOver 500 cmdlets to integrate with SharePointSharePoint Management Console = PowerShellRemoting allows administrate entire farm centrally

Twitter hashtag: #SPSNYCWhatif and Confirm clausesAppending -whatif to commandlet allows seeing potential outcome without executing

Ex. Remove-SPWeb url http://site whatif

Appending -confirm prompts user for confirmation before executing

Ex. Remove-SPWeb url http://site confirmTwitter hashtag: #SPSNYCConclusionPowerShell is a new scripting admin toolSyntax and how to useBasic demos for file system and SharePointHopefully had a few laughs as wellTwitter hashtag: #SPSNYCReferencesPowerShell Product Homepagehttp://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx

PowerShell Script Centerhttp://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx

PowerShell Owners Manual (good intro walkthroughs)http://www.microsoft.com/technet/scriptcenter/topics/winpsh/manual/default.mspx

PowerShell Communityhttp://powershellcommunity.org

PowerShell and SharePoint 2010http://stsadm.blogspot.com/2009/10/sharepoint-2010-stsadm-and-powershell.html Twitter hashtag: #SPSNYCQ&A

Twitter hashtag: #SPSNYCThank you for attending!

Twitter hashtag: #SPSNYC2 ASUS NetbooksAlso Some Books1 Typemock Isolator LicenseA 2-5 Day Course from SetFocus on SharePointTelerik RAD Controls Set1 DeliverPoint WFE 2010 license (Worth $1500)1 BCS Meta Man license (Worth $1200)1 Lightning Conductor 2010 WFE license (Worth $800)1 Lightning Storm Forums license. (Worth $600)

Remember to fill out your evaluations for your chance to win cool prizes3 Apple IPAD 32 GB Wifi