0% found this document useful (0 votes)
295 views

SharePoint Online Administration With PowerShell

The document discusses using PowerShell and the Client-Side Object Model (CSOM) to administer SharePoint Online sites and tenant settings. It describes how the SharePoint Online Management Shell provides basic site collection and user administration capabilities through PowerShell cmdlets. However, CSOM is needed to perform more advanced tasks and work with site content because the cmdlets have limitations. The document provides examples of using both PowerShell and CSOM to manage terms, user profiles, sites collections and more across SharePoint Online and on-premises environments.

Uploaded by

Eduardo Martinez
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
295 views

SharePoint Online Administration With PowerShell

The document discusses using PowerShell and the Client-Side Object Model (CSOM) to administer SharePoint Online sites and tenant settings. It describes how the SharePoint Online Management Shell provides basic site collection and user administration capabilities through PowerShell cmdlets. However, CSOM is needed to perform more advanced tasks and work with site content because the cmdlets have limitations. The document provides examples of using both PowerShell and CSOM to manage terms, user profiles, sites collections and more across SharePoint Online and on-premises environments.

Uploaded by

Eduardo Martinez
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 52

SharePoint Online Administration

with PowerShell

Technical Track
Brendan Griffin
 Brendan Griffin – @brendankarl | brendan-griffin.com
 Senior Premier Field Engineer @ Microsoft
 Microsoft Certified Master – SharePoint 2010
 SharePoint-er since 2004
Agenda
 The “Challenge”
 The Solution
 Drawbacks
 CSOM to the Rescue!
The Challenge
 SharePoint administrators rely heavily on
PowerShell
 Office 365 is a $1.5 billion a year business and
growing
 What does the increased adoption of Office 365
mean for traditional SharePoint administrators?
The Challenge
 Does No Server Access == No PowerShell?
 Are we back in the dark ages of GUI based
administration?
The Solution
 Of course not!
 A number of PowerShell Cmdlets are available for
SharePoint Online
 Download the SharePoint Online Management Shell
to get started here
SharePoint Online Management Shell
 So, I’ve installed it – what next?
 Let’s take a closer look:

 Focused on Site Collection and User


administration tasks
SharePoint Online Management Shell
 Includes 30 Cmdlets, which is slightly less than On-
Premises! Link
O365 vs. On Premises Cmdlets

 Get-SPOSite  Get-SPSite
 Set-SPOSite  Set-SPSite
 New-SPOSite  New-SPSite
 Remove-SPOSite  Remove-SPSite
 New-SPOUser  New-SPUser
 …  …

 Spot the difference?


O365 vs. On Premises Cmdlets
 “I will only need to make minor changes to my scripts” –
Brendan Griffin (2013)
 Wrong!!! – Cmdlets aren’t functionally equivalent
 Have different Methods and Properties
 In some cases behave differently
O365 vs. On Premises Cmdlets
 Example:
 Get-SPSite returns all Site Collections
 Get-SPOSite returns all Site Collections except My Sites
 In some cases limitations can be addressed using a
different approach – more on this later…
 Let’s take a look at some of the Cmdlets in action…
SPOL Management Shell – Getting Started

 Import the Microsoft.Online.SharePoint.PowerShell Module


 Use Connect-SPOService to connect to the Tenant
Get-SPOSite Summary
 Use the –Detailed parameter with Get-SPOSite if you need the
following properties returned
 LockIssue
 WebsCount
 CompatibilityLevel
 AllowSelfServiceUpgrade
 ResourceUsageCurrent
 ResourceUsageAverage
 StorageUsageCurrent
What Sites Do I Have?
 Inventory all Site Collections and output results to a
CSV file using Get-SPOSite
Who Has Access?
 List the SharePoint Groups that each user is a member
of within a Site Collection using Get-SPOUser
Site Level Administration
 Set-SPOSite can be used to:
 Change Site Owner

 Configure the Storage and Resource Quota

 Change the Title


Site Level Administration
 Set-SPOSite can also be used to:
 Lock a Site

 Requests to Sites that are locked can be redirected to a


specific URL

 Redirect URL is configurable using


Set-SPOTenant -NoAccessRedirectURL
Tenant Level Settings
 Get-SPOTenant can be used to retrieve Tenant level
settings
Configuring External Access

 Configure the External Sharing Capability for a specific


Site Collection
 Use Set-SPOSite with the SharingCapability
parameter, options:
 Disabled
 ExternalUserAndGuestSharing
 ExternalUserSharingOnly
Auditing External Access
 Who has access? Where do they have access? Who
invited them?
How Does this Actually Work?
 Get-SPOSite “Under the Covers”
 Connect to the client.svc WCF service and sends a
request as XML
Under the Covers: Get-SPOSite
 Response is returned as JSON:
But, What about X?
 SPOL Management Shell is great for basic Site
Collection and User administration
 But…
 I can do x On-Premises, it doesn’t appear to be possible to do
this using the SPOL Management Shell?
 I need to do something with Managed Metadata, User Profiles
and Search, why isn’t there a Cmdlet?
CSOM to the Rescue!
 The Client Side Object Model was introduced in
SharePoint 2010 and is available in SharePoint Online
 Provides a subset of the Server Object Model
 Can be executed remotely using JavaScript or .NET
Getting Started with CSOM
 Download the SharePoint Online Client Components
SDK here
 Includes the DLLs required for CSOM
 Fire up PowerShell and away we go…
CSOM – What Went Wrong?
 CSOM is different to the Server Side Object Model
 To minimize data transfer a slightly different approach
is used
 Requests are bundled together and then sent to the
server for execution
 Only when an object has been returned, can it be used
CSOM: 4 Steps to Success
1. Create Variable
2. Load into the Context
3. Execute the Query
4. Use the Variable
Using CSOM to Create a Web
Using CSOM to Create a Web
What about Service Applications?
 CSOM can also be used with Managed Metadata,
Search and User Profiles
 The relevant assemblies need to be referenced
 Microsoft.SharePoint.Client.Taxonomy.dll (Managed Metadata)
 Microsoft.SharePoint.Client.Search.dll (Search)
 Microsoft.SharePoint.Client.UserProfiles.dll (User Profiles)
Exporting all User Profiles?
Exporting all User Profiles?
Adding Terms to the Term Store?
Adding Terms to the Term Store?
Adding Terms to the Term Store?
Next Steps…
 Need to do something else?
 Refer to the Microsoft.SharePoint.Client namespace
documentation on MSDN
 The possibilities are endless (kind of!)
Next Steps…
 SharePoint 2013 Client Browser is a great tool to
determine the data that can be obtained using CSOM
Better Together
 CSOM and the SPOL Management Shell can be used
together
 Why?
 Management Shell is scoped at the Tenant level
 Able to connect to a Site Collection but cannot go deeper into
the hierarchy
 CSOM is scoped at the Site Collection level
 Able to work with Webs, Lists, Items…
 Used together the possibilities are endless!
Better Together
 Example:
 Use the SPOL Management Shell to identify the URLs for
each Site Collection within a Tenant
 Pass the URLs to CSOM
 CSOM can connect to the Site Collection
 Return useful information
– Webs
– Users
– Lists
– Features
Better Together
Better Together
CSOM to the Rescue – My Sites
 In preparation for v15 upgrades, I needed a list of all My
Sites running in v14 mode within a Tenant
 Get-SPOSite doesn’t return My Sites
 With a little CSOM magic this is possible
 How?
 Connect to the User Profile Service
 Return the My Site URL for each user
 Connect to each My Site
 Retrieve the CompatibilityLevel property
CSOM to the Rescue – My Sites
CSOM to the Rescue – My Sites
CSOM On-Premises?
 CSOM can also be used On-Premises
 Download the SharePoint Server 2013 Client
Components SDK
 Scripts could be run against SharePoint Online and On-
Premises*
Summary
 PowerShell can be used to administrate
SharePoint Online
 The Management Shell provides basic
capabilities
 CSOM can be used to supplement
Thank you for attending!

You might also like