Painless PowerShell for SharePoint Admins Rick Taylor
Special Thanks to our Platinum Sponsor …and our Gold Sponsor
Who am I??? Who am I ??????????
Rick Taylor, MCSE, MCT SharePoint architect, formerly with Microsoft SharePoint Platform Architecture Team for SharePoint Online (O365) Contact
Agenda What is Windows PowerShell Windows PowerShell basics Windows PowerShell scripts for administrators
Command-line interface and scripting language used for SharePoint Server administration Complements CMD Extends STSADM Uses XML & Objects Built on the.Net Framework What is Windows PowerShell?
cmdlet pronounced "command-let“ More than 500 cmdlets for SharePoint alone Windows PowerShell Basics
©2012 Microsoft Corporation. All rights reserved.
SharePoint 2013 Nouns and Verbs 774 Total commands Nouns start with SP 334 Nouns
Windows PowerShell Basics cmdlets = verbs (actions) & nouns (objects) Combine the two to build specific commands Examples Get-SPSite Get = Verb SPSite = Noun
Get a list of all commands: Get-Command –noun sp* Get help for a specific command: Get-Help Getting the list of SharePoint cmdlets
Windows PowerShell for SharePoint Command Builder
For more detailed help add the following parameters: Get-Help -full Get-Help -examples Get-Help -detailed Getting the list of SharePoint cmdlets
Differences in Get-help: -full
Differences in Get-help: -detailed
Differences in Get-help: - examples
-WhatIf Evaluate what happens without side-effects
©2012 Microsoft Corporation. All rights reserved.
Adding SharePoint Snap-In to ISE
Checking out Windows PowerShell DEMO
Build scripts to easily execute through common commands and tasks Develop using PowerShell ISE or other shells Schedule using Task Scheduler. PowerShell Scripts
SharePoint Basic Site Structure
Site Structure Creation CommandDescription New-SPManagedAccountRegisters a new managed account New-SPWebApplicationCreates a new web application New-SPContentDatabaseCreates a new content database for a web application New-SPManagedPathCreates a managed path New-SPSiteCreates a new site collection New-SPWebCreates a new web within a site collection
Permissions for Shell Admins for Backup and Restore Farm componentMember of Administrators group on the local computer Member of Farm Administrators SharePoint group Full Control on backup folder FarmYesNoYes Service applicationYesNoYes Content databaseYesNoYes Site collectionNoYes Site, list, document library YesNoYes
Examples: Activate a feature across multiple site collections Provisioning of Managed Accounts Creating of New Sites Backup all Site Collections in Farm PowerShell Scripts
Service Application Setup/Configuration Cmdlet NameExample Get-SPServiceInstance $svc = (Get-SPServiceInstance | ? {$_.TypeName -eq "Managed Metadata Web Service"}) Start-SPServiceInstance if ($svc.Status –eq "Disabled") { $svc | Start-SPServiceInstance } while($svc.Status -ne "Online") { Write-Host "Waiting to provision"; sleep 5; } New-SP*ServiceApplication PS C:\> Get-Command New-SP*ServiceApplication New-SP*ServiceApplicationProxy PS C:\> Get-Command New-SP*ServiceApplicationProxy New-SPServiceApplicationProxyGroup Add-SPServiceApplicationProxyGroupMember New-SPServiceApplicationProxyGroup "Demo" $mms = Get-SPServiceApplicationProxy | ?{$_.TypeName -eq "Managed Metadata Service Connection"} Add-SPServiceApplicationProxyGroupMember -Identity "Demo" - Member $mms
Connect-SPOService –Url –credential
PS C:\windows\system32> get-command -noun spo* | Group Noun Count Name Group SPOUser {Add-SPOUser, Get-SPOUser, Remove-SPOUser, S... 2 SPOService {Connect-SPOService, Disconnect-SPOService} 1 SPOAppErrors {Get-SPOAppErrors} 1 SPOAppInfo {Get-SPOAppInfo} 3 SPODeletedSite {Get-SPODeletedSite, Remove-SPODeletedSite,... 2 SPOExternalUser {Get-SPOExternalUser, Remove-SPOExternalUser} 7 SPOSite {Get-SPOSite, New-SPOSite, Remove-SPOSite, R... 4 SPOSiteGroup {Get-SPOSiteGroup, New-SPOSiteGroup, Remove SPOTenant {Get-SPOTenant, Set-SPOTenant} 1 SPOTenantLogEntry {Get-SPOTenantLogEntry} 1 SPOTenantLogLastAvaila... {Get-SPOTenantLogLastAvailableTimeInUtc} 1 SPOWebTemplate {Get-SPOWebTemplate} 1 SPOUpgradeEvaluationSite {Request-SPOUpgradeEvaluationSite}
Windows PowerShell for SharePoint Foundation us/library/ee662510(office.14).aspx us/library/ee662510(office.14).aspx Windows PowerShell Getting Started Guide us/library/aa973757(VS.85).aspx us/library/aa973757(VS.85).aspx Windows PowerShell Cheat Sheet STSADM to Windows PowerShell mapping Zach Rosenfield’s blog Additional PowerShell Resources