PowerShell Administration with SharePoint 2013 and SharePoint ...

53

Transcript of PowerShell Administration with SharePoint 2013 and SharePoint ...

Page 1: PowerShell Administration with SharePoint 2013 and SharePoint ...
Page 2: PowerShell Administration with SharePoint 2013 and SharePoint ...

PowerShell Administration with SharePoint 2013 and SharePoint OnlineCorey Roth@coreyroth

OFC-B328

Page 3: PowerShell Administration with SharePoint 2013 and SharePoint ...

Agenda & Key TakeawaysConfiguring PowerShell permissionsPowerShell for UpgradesUseful scriptsPowerShell with SharePoint OnlineUsing client object model with SPOPowerShell Tips

Page 4: PowerShell Administration with SharePoint 2013 and SharePoint ...

Getting StartedLaunch with:SharePoint 2013 Management Shell linkRun SharePoint.ps1 (Add-PSSnapin Microsoft.SharePoint.PowerShell)

Page 5: PowerShell Administration with SharePoint 2013 and SharePoint ...

AssumptionsYou have a basic understanding of PowerShellYou’re interested in doing “real stuff” with PSYou want to know more than the basics

Page 6: PowerShell Administration with SharePoint 2013 and SharePoint ...

PermissionsMany installations do not have permissions correctFarm / local administrator is NOT enoughDon’t use the farm account!PowerShell is more forgiving in SharePoint 2013Permissions for PowerShell are now configured OOTBDon’t forget to run as administrator

Page 7: PowerShell Administration with SharePoint 2013 and SharePoint ...

Granting permission to PowerShellGet-SPShellAdmin – determine access to PowerShellAdd-SPShellAdmin – add users to PowerShellMust execute for each content databaseGet-SPShellAdminAdd-SPShellAdmin –username sharepoint\sp_newadmin

$database = Get-SPContentDatabase MyContentDbAdd-SPShellAdmin –username domain\username –database $database

Page 8: PowerShell Administration with SharePoint 2013 and SharePoint ...

Add-SPShellAdminCorey Roth@coreyroth

Page 9: PowerShell Administration with SharePoint 2013 and SharePoint ...

Getting ready for Upgrade

Page 10: PowerShell Administration with SharePoint 2013 and SharePoint ...

Getting Ready for UpgradeTest-SPContentDatabase and Mount-SPContentDatabase still usedDeferred Site Collection Upgrade = New cmdletsTest-SPContentDatabase –Name Wss_Content –WebApplication http://servername

Mount-SPContentDatabase –Name Wss_Content –WebApplication http://servername

Page 11: PowerShell Administration with SharePoint 2013 and SharePoint ...

Content Database UpgradeCorey Roth@coreyroth

Page 12: PowerShell Administration with SharePoint 2013 and SharePoint ...

Deferred Site Collection UpgradesCmdlets to:Manage Health ChecksUpgradeRequest Evaluation Site CollectionsCopy

View upgrade status with Get-SPSite

Page 13: PowerShell Administration with SharePoint 2013 and SharePoint ...

Site Collection Health ChecksTest-SPSiteRuns Site Collection Health ChecksAll rules by default or specify specific rule

Repair-SPSiteAutomatically repairs all issues

Test-SPSite –Identity http://server/sitecollection

Repair-SPSite –Identity http://server/sitecollection

Page 14: PowerShell Administration with SharePoint 2013 and SharePoint ...

Upgrading Site CollectionsUpgrade-SPSiteStarts Upgrade Process on Site CollectionAlso resumes failed upgrades-Unthrottled – bypasses throttle limits-VersionUpgrade – used to upgrade from version 14

Upgrade-SPSite http://server/sitecollection -VersionUpgrade

Page 15: PowerShell Administration with SharePoint 2013 and SharePoint ...

Monitoring Upgrade StatusGet-SPSiteUpgradeSessionReports upgrade status for content db and site collectionUse with -ContentDatabase or -Site

Content Database requires a filter parameter:-HideWaiting-ShowCompleted-ShowFailed-ShowInProgressGet-SPSiteUpgradeSession –Site http://server/sitecolection

$database = Get-SPContentDatabase MyContentDbGet-SPSiteUpgradeSession –ContentDatabase $database -ShowInProgress

Page 16: PowerShell Administration with SharePoint 2013 and SharePoint ...

Upgrade Evaluation Site CollectionsRequest-SPUpgradeEvaluationSiteRequests an upgrade evaluation site collectionTarget URL auto-generated-Email – specify whether site collection owner and farm admin receive notification

Request-SPUpgradeEvaluationSite http://server/sitecollection

Page 17: PowerShell Administration with SharePoint 2013 and SharePoint ...

Copying Site CollectionsCopy-SPSiteCopies a site collection to a new URL-Identity – source URL-TargetUrl – destination URL-DestinationDatabase (optional) – name of new database

Copy-SPSite http://server/sitecollection -DestinationDatabase MyContentDb -TargetUrl http://server/sitecollection2

Page 18: PowerShell Administration with SharePoint 2013 and SharePoint ...

Site Collection UpgradeCorey Roth@coreyroth

Page 19: PowerShell Administration with SharePoint 2013 and SharePoint ...

When tools are needed

Page 20: PowerShell Administration with SharePoint 2013 and SharePoint ...

Windows PowerShell for SharePoint Command Builder

Page 21: PowerShell Administration with SharePoint 2013 and SharePoint ...

PowerShell Command Builder and ScriptsCorey Roth@coreyroth

Page 22: PowerShell Administration with SharePoint 2013 and SharePoint ...

Licensing

Page 23: PowerShell Administration with SharePoint 2013 and SharePoint ...

The ChallengeOnly some users need Enterprise featuresPreviously, no way to audit Enterprise useSharePoint 2013 License Checking feature helps

Page 24: PowerShell Administration with SharePoint 2013 and SharePoint ...

SharePoint 2013 LicensingMap license types to AD GroupsEnterpriseStandardProjectOfficeWebAppEdit

Standard users blocked from Enterprise featuresEnterprise Web Parts blocked from Add Web Part menuLicense Error on existing web parts

Disabled by defaultEnable with SP-EnableUserLicensing

Page 25: PowerShell Administration with SharePoint 2013 and SharePoint ...

License MappingGet-SPUserLicenseShows available license types (i.e.: Standard or Enterprise)

New-SPUserLicenseMappingMaps an AD group to a license typeAlso supports roles and claims-SecurityGroup – Active Directory Group-License – License type

Add-SPUserLicenseMappingAdds the new license mappingNo parameters, pipe input from New-SPUserLicenseMapping

Page 26: PowerShell Administration with SharePoint 2013 and SharePoint ...

Enable / Disable LicensingEnable-SPUserLicenseActivates license checking modeNo parameters necessary

Disable-SPUserLicenseDeactivates license checking modeNo parameters necessary

Page 27: PowerShell Administration with SharePoint 2013 and SharePoint ...

Enabling Licensing$standardusers = New-SPUserLicenseMapping –SecurityGroup “SharePoint Standard Users” –License Standard$enterpriseusers = New-SPUserLicenseMapping – SecurityGroup “SharePoint Enterprise Users” –License Enterprise

$standardusers | Add-NewSPUserLicenseMapping$enterpriseusers | Add-NewSPUserLicenseMapping

SP-EnableUserLicensing

Page 28: PowerShell Administration with SharePoint 2013 and SharePoint ...

License Mapping

Corey Roth@coreyroth

Page 29: PowerShell Administration with SharePoint 2013 and SharePoint ...

SharePoint Online

Page 30: PowerShell Administration with SharePoint 2013 and SharePoint ...

Getting Started with PowerShell and SPOInstall Windows PowerShell 3.0 from Windows Management Framework 3.0 (Windows 7)Already included with Windows 8 / 8.1 and SharePoint 2013

Install SharePoint Online Management Shellhttp://bit.ly/1hHX5qR

Identify your global administrator accountLaunch SharePoint Online Management ShellMicrosoft.Online.SharePoint.PowerShell.dll

Page 31: PowerShell Administration with SharePoint 2013 and SharePoint ...

PowerShell for SPO TipsRemember to use https instead of httpCommands have similar namesGet-SPO prefix

Global Administrator account requiredUse -NoWait for cmdlet to execute immediately

Page 32: PowerShell Administration with SharePoint 2013 and SharePoint ...

Connecting to SharePoint OnlineConnect-SPOServiceConnects to SharePoint Online-Url – URL to SharePoint Online tenant administration

i.e.: https://mytenant-admin.sharepoint.com-Credential – complete username of a global administrator

i.e.: [email protected]

Connect-SPOService –Url https://mytenant-admin.sharepoint.com –Credential [email protected]

Page 33: PowerShell Administration with SharePoint 2013 and SharePoint ...

What commands are available?Get-Command –Module Microsoft.Online.SharePoint.PowerShell

Page 34: PowerShell Administration with SharePoint 2013 and SharePoint ...

Working with Site CollectionsGet-SPOSiteReturns one or more site collections-Identity (optional) – URL of site collection-Limit (optional) – number of site collections to return

Default 200, ALL can be used-Filter (optional) – server side filtering using { }

Used in lieu of –IdentityNote case sensitive operators (-like, -notlike, -eq, -ne)

-Detailed – Returns non-default properties such as CompatibilityLevel

Get-SPOSiteGet-SPOSite -Detailed

Get-SPOSite –Identity https://mytenant.sharepoint.com

Get-SPOSite –Filter {Url -like “*term*}

Page 35: PowerShell Administration with SharePoint 2013 and SharePoint ...

Creating new Site CollectionsNew-SPOSiteCreates a site collection-Url – full URL of new site collection-Owner – full user name of site owner

i.e.: [email protected] – in MB-Template (Optional) – i.e.: STS#0

Get-SPOWebTemplate – returns all installed site templates-Title (Optional) – name of site collection

New-SPOSite -Url https://mytenant.sharepoint.com/sites/mynewsite -Owner [email protected] -StorageQuota 1000 -Title "My new site collection“ –Template STS#0

Page 36: PowerShell Administration with SharePoint 2013 and SharePoint ...

Deleting Site CollectionsRemove-SPOSiteMoves site collection to recycle bin-Identity – URL of site collectionSupports –confirm and -NoWait

Remove-SPOSite –Identity http://mytenant.sharepoint.com/sites/sitename -NoWait

Page 37: PowerShell Administration with SharePoint 2013 and SharePoint ...

Restoring Site CollectionsRestore-SPODeletedSiteRestores a site collection from the recycle bin-Identity – URL of site collection

Restore-SPODeletedSite –Identity http://mytenant.sharepoint.com/sites/sitename -NoWait

Page 38: PowerShell Administration with SharePoint 2013 and SharePoint ...

Working with UsersGet-SPOUser-Site – full URL of site collection-LoginName (Optional) – specific user account name

i.e.: [email protected]

Add-SPOUserAdds existing user to a SharePoint Group-Site – full URL of site collection-LoginName – specific user account name-Group – SharePoint group

Get-SPOUser -Site https://mytenant.sharepoint.com -LoginName [email protected] Add-SPOUser -Site https://mytenant.sharepoint.com -LoginName [email protected] -Group "Team Site Members“

Page 39: PowerShell Administration with SharePoint 2013 and SharePoint ...

PowerShell with SharePoint OnlineCorey Roth@coreyroth

Page 40: PowerShell Administration with SharePoint 2013 and SharePoint ...

What's missing?

Page 41: PowerShell Administration with SharePoint 2013 and SharePoint ...

PowerShell with the Client Object Model

Page 42: PowerShell Administration with SharePoint 2013 and SharePoint ...

Why CSOM?Many functions not available in PowerShell for SPOCSOM lets us do things such asWork with sitesCreate listsActivate features (even hidden ones)

Page 43: PowerShell Administration with SharePoint 2013 and SharePoint ...

Steps for using CSOM with PowerShellInstall CSOM libraries or run from SharePoint 2013Use Add-Type to reference CSOM libraries Microsoft.SharePoint.Client.dll Microsoft.SharePoint.Client.Runtime.dll

Create ClientContext objectAuthenticate to SPOLoad objectsCall ExecuteQuery()

Page 44: PowerShell Administration with SharePoint 2013 and SharePoint ...

PowerShell and CSOMCorey Roth@coreyroth

Page 45: PowerShell Administration with SharePoint 2013 and SharePoint ...

PowerShell Tips

Page 46: PowerShell Administration with SharePoint 2013 and SharePoint ...

Use PowerShell More EffectivelyUse the TAB key!Enumerators-Debug-WhatIf

Page 47: PowerShell Administration with SharePoint 2013 and SharePoint ...

Agenda & Key TakeawaysConfiguring PowerShell permissionsPowerShell for UpgradesUseful scriptsPowerShell with SharePoint OnlineUsing client object model with SPOPowerShell Tips

Page 48: PowerShell Administration with SharePoint 2013 and SharePoint ...

ResourcesSite Collection Upgrades with PowerShellhttp://bit.ly/Su5GTQ

Create and Manage SPO sites with PowerShellhttp://bit.ly/1mw0lZn

Page 49: PowerShell Administration with SharePoint 2013 and SharePoint ...
Page 50: PowerShell Administration with SharePoint 2013 and SharePoint ...

ResourcesLearning

Microsoft Certification & Training Resourceswww.microsoft.com/learning

msdnResources for Developers

http://microsoft.com/msdn

TechNetResources for IT Professionals

http://microsoft.com/technet

Sessions on Demandhttp://channel9.msdn.com/Events/TechEd

Page 51: PowerShell Administration with SharePoint 2013 and SharePoint ...

Complete an evaluation and enter to win!

Page 52: PowerShell Administration with SharePoint 2013 and SharePoint ...

Evaluate this session

Scan this QR code to evaluate this session.

Page 53: PowerShell Administration with SharePoint 2013 and SharePoint ...

© 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.