SlideShare a Scribd company logo
WWW.COLLAB365.EVENTS
PowerShell for Office 365
WWW.COLLAB365.EVENTS
Vlad Catrinescu
vNext Solutions
Email : vlad@vnext.solutions
Twitter : @vladcatrinescu
LinkedIn :
http://spvlad.com/VladLnkd
• Montreal, Canada
• SharePoint-Community.net Co-Founder
• Pluralsight Author
Contact Details:
3
Agenda
PowerShell for Office 365
PowerShell Tips & Tricks Users and Licensing SharePoint Online
Exchange Online Advanced Scripting Questions
Tips and Tricks
Let’s learn the basics!
5
Getting Help
Get-Command
C Gets All the commandlets
installed on your computer.
Get-Help
H Displays Additional information
about a commandlet
Get-Member
M View all the properties
.CHM
6
Keyboard Shortcuts
• Ctrl+Left arrow / Ctrl+Right
arrow
 Move to the next word
• F7
 Displays a pop-up window
with your command history
• F9
 Runs a specific number
command
• Tab
 Autocomplete command
7
Including Other Files
8
Text File
$servers = get-Content C:Scriptsinput.txt
foreach ($server in $servers) {
Write-Host $line
}
9
CSV File
$users = import-csv C:ScriptsUsers.csv
foreach ($user in $users) {
$UserName = $user.Name
$UserDept = $user.Department
$UserTitle = $user.Title
Write-host "$UserName is a $UserTitle in the $UserDept
department."}
Users and Licensing
Let’s learn how to manage our users, grant and
remove their licenses.
11
Connecting to Office 365
Requirements
• Office 365 Administrator rights
• 64-bit Machine
• Windows 7 SP1 +
• Windows Server 2008R2 +
12
Connecting to Office 365
Software:




13
Connecting to Office 365
Import Module
Get Credential
Establish Connection
14
Connecting to Office 365
#Import Module into PowerShell Session
Import-Module MSOnline
#Get Connection Credential
$cred = get-credential
#Establish Connection
Connect-MsolService -Credential $cred
15
Get-MsolUser
New-MsolUser
Set-MsolUser
Users
PowerShell Commandlets
Get-MsolSubscription
New-MsolLicenseOptions
Set-MsolUserLicense
Licenses
Get-MsolGroup
New-MsolGroup
Set-MsolGroup
Groups and Roles
16
PowerShell Commandlets
Get-MsolUser
New-MsolUser
Set-MsolUser
Get-MsolSubscription
New-MsolLicenseOptions
Set-MsolUserLicense
Get-MsolGroup
New-MsolGroup
Set-MsolGroup
<Verb> - Msol<noun>
SharePoint Online
Let’s learn how to manage Site Collections,
Tenants and Users
18
Connecting to SharePoint Online
Requirements:



19
Connecting to SharePoint Online
Open SharePoint
Management Shell
Get Credential
Establish Connection
20
Connecting to SharePoint Online
#Get connection credential
$cred = get-credential
#Establish connection
Connect-SPOService
-Url https://<SP Admin Center>.sharepoint.com
-credential $cred
21
PowerShell Commandlets
905
30
0
200
400
600
800
1000
SharePoint 2013 SharePoint Online
Number of PowerShell Cmdlets
Number of Cmdlets
22
PowerShell Commandlets
• Install
• Configure
• Update
• Web Application
• Site Collection
• SPWeb
• SPList
• SPItem
SharePoint On Premises
• Tenant
• Site Collection
• SPWeb (very limited)
SharePoint Online
23
PowerShell Commandlets
Get-SPOAppErrors Remove-SPOExternalUser Repair-SPOSite
Get-SPOAppInfo Connect-SPOService Set-SPOSite
Get-SPODeletedSite Disconnect-SPOService Test-SPOSite
Remove-SPODeletedSite Get-SPOSite Upgrade-SPOSite
Restore-SPODeletedSite New-SPOSite Get-SPOSiteGroup
Get-SPOExternalUser Remove-SPOSite New-SPOSiteGroup
Remove-SPOUser Set-SPOUser Remove-SPOTenantSyncClientRestriction
Add-SPOUser Get-SPOUser Get-SPOTenantSyncClientRestriction
Get-SPOWebTemplate Get-SPOTenant Request-SPOUpgradeEvaluationSite
Remove-SPOSiteGroup Set-SPOTenant Set-SPOTenantSyncClientRestriction
Set-SPOSiteGroup Get-SPOTenantLogEntry Get-SPOTenantLogLastAvailableTimeInUtc
SPO
=
Exchange Online
Let’s Learn how to manage Exchange Online
Mailboxes & Distribution lists
25
Connecting to SharePoint Online
Requirements:

26
Connecting to Exchange Online
Get Credential
Establish connection
Import remote
session
27
Connecting to Exchange Online
#Get Connection Credential
$cred = get-credential
#Establish Connection
$Session = New-PSSession
-ConfigurationName Microsoft.Exchange
-ConnectionUri https://outlook.office365.com/powershell-liveid/
-Credential $cred
-Authentication Basic
-AllowRedirection
#Add Remote Session into current session
Import-PSSession $Session
28
PowerShell Commandlets
Disable-Mailbox Get-InboundConnector Get-DistributionGroup
Enable-Mailbox New-InboundConnector New-DistributionGroup
Get-Mailbox Remove-InboundConnector Remove-DistributionGroup
New-Mailbox Set-InboundConnector Set-DistributionGroup
Remove-Mailbox Get-OutboundConnector Add-DistributionGroupMember
Search-Mailbox Get-MailContact Get-UnifiedGroup
Set-Mailbox New-MailContact New-UnifiedGroup
Add-RecipientPermission Remove-MailContact Remove-UnifiedGroup
Get-RecipientPermission Set-MailContact Set-UnifiedGroup
Disable-Mailbox Get-Contact Add-UnifiedGroupLinks
Advanced Scripting
Let’s take it to the next level!
30
Advanced Scripting
31
Connecting to all Services
Steps:
1. Get Connection Credential
2. Import Modules
3. Create Sessions
4. Connect to Services
5. Import Sessions
32
Connecting to all the services
#Get Connection Credential
$cred = get-credential
#Import Modules
Import-Module MsOnline, Microsoft.Online.SharePoint.PowerShell
#Create Sessions
$exchange = New-PSSession -ConfigurationName Microsoft.Exchange –ConnectionUri
"https://outlook.office365.com/powershell-liveid/" -Credential $cred -Authentication
"Basic" –AllowRedirection
#Connect to Sevices
Connect-MsolService -Credential $cred
Connect-SPOService -Url https://tenant.sharepoint.com -credential $cred
#Import Sessions
Import-PSSession $exchange
33
CSOM For SharePoint Online
• Client Side Object Model
• Used to develop code that runs
outside of the SharePoint server
34
CSOM For SharePoint Online
1. Get Client Context
• Class that manages the interaction between
our script and the SharePoint server.
2. Do the required action
35
Get All Lists in a Website
function Get-ClientContext($UserPrincipalName,$SecurePassword,$Url){
$clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($Url)
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserPrincipalName, $SecurePassword)
$clientContext.Credentials = $credentials
return $clientContext }
#Initial Variables
$User = "vlad@globomantics.org"
$File = "C:ScriptsPassword.txt"
$Site = "https://globomanticsorg.sharepoint.com"
$Password = Get-Content $File | ConvertTo-SecureString
#Get Context
$Context = Get-ClientContext $User $Password $Site
$lists = $Context.Web.Lists
$context.Load($lists)
$context.ExecuteQuery()
#Loop trough lists
foreach ($list in $lists) {
Write-Host $list.Title }
36
Community Extensions
https://github.com/OfficeDev/PnP-PowerShell
Download
• Program ran mostly by Microsoft
• 134 Cmdlets
OfficeDev PnP-PowerShell
https://github.com/OfficeDev/PnP-
PowerShell/blob/master/Documentation/readme.md
Documentation
37
Get All Lists in a Website
$User = "vlad@globomantics.org"
$File = "C:ScriptsPassword.txt"
$cred=New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, (Get-Content
$File | ConvertTo-SecureString)
Connect-SPOnline
-Url https://globomanticsorg.sharepoint.com
-Credentials $cred
Get-SPOList
Questions?
39
01
02
03
04
Resources
Course coming soon! 2+ hours of PowerShell for Office 365
Awesomeness!
Pluralsight
http://powershell.office.com/
PowerShell for Office 365 Portal
http://blogs.technet.com/b/heyscriptingguy/
Hey, Scripting Guy! Blog
https://github.com/OfficeDev/PnP-powershell
PnP-PowerShell
40
Questions?
Vlad Catrinescu
@vladcatrinescu
www.absolute-sharepoint.com
http://www.pluralsight.com/author/vlad-catrinescu

More Related Content

PDF
Z01 etano installation_guide
PPT
Get Real: Adventures in realtime web apps
PDF
DCHQ Cloud Application Platform | Linux Containers | Docker PaaS
PPTX
Intro to PowerShell
PPTX
Take Command of WordPress With WP-CLI
KEY
TDD of HTTP Clients With WebMock
PDF
Testing http calls with Webmock and VCR
PPTX
the Stairway to PowerShell in Office365
Z01 etano installation_guide
Get Real: Adventures in realtime web apps
DCHQ Cloud Application Platform | Linux Containers | Docker PaaS
Intro to PowerShell
Take Command of WordPress With WP-CLI
TDD of HTTP Clients With WebMock
Testing http calls with Webmock and VCR
the Stairway to PowerShell in Office365

Similar to Collab365: PowerShell for Office 365 (20)

PDF
SharePoint Saturday New York: PowerShell for Office 365
PDF
VMUG - Using PowerShell to call RESTful APIs
PPTX
PowerShell for SharePoint Admins
PPTX
SPugPt Meeting 35: Manage govern and drive adoption of share point online wit...
PPTX
Introduction to PowerShell - Be a PowerShell Hero - SPFest workshop
PPTX
Getting Started with PowerShell for Office 365
PPTX
SPSTC - PowerShell - Through the SharePoint Looking Glass
PPTX
Power shell for sp admins
PPTX
Brian Jackett: Managing SharePoint 2010 Farms with Powershell
PPTX
Brian Jackett: Managing SharePoint 2010 Farms with Powershell
PDF
Operacion Guinda 2
PDF
Microsoft-365-Administrator-s-Guide1.pdf
PPTX
CCI2019 - I've got the Power! I've got the Shell!
PPTX
How to do everything with PowerShell
PDF
2019-05-16 aOS Luxembourg - 6 - Flow avancé - Serge Luca
PPTX
PowerShell: Through the SharePoint Looking Glass
PPTX
Introduction to PowerShell for SharePoint Admins and Developers - SharePoint ...
PDF
Sql Server & PowerShell
PPTX
SharePoint Saturday Ottawa 2015 - Office 365 and PowerShell - A match made in...
PPTX
Doctor Flow- Best practices Microsoft flow - Techorama 2019
SharePoint Saturday New York: PowerShell for Office 365
VMUG - Using PowerShell to call RESTful APIs
PowerShell for SharePoint Admins
SPugPt Meeting 35: Manage govern and drive adoption of share point online wit...
Introduction to PowerShell - Be a PowerShell Hero - SPFest workshop
Getting Started with PowerShell for Office 365
SPSTC - PowerShell - Through the SharePoint Looking Glass
Power shell for sp admins
Brian Jackett: Managing SharePoint 2010 Farms with Powershell
Brian Jackett: Managing SharePoint 2010 Farms with Powershell
Operacion Guinda 2
Microsoft-365-Administrator-s-Guide1.pdf
CCI2019 - I've got the Power! I've got the Shell!
How to do everything with PowerShell
2019-05-16 aOS Luxembourg - 6 - Flow avancé - Serge Luca
PowerShell: Through the SharePoint Looking Glass
Introduction to PowerShell for SharePoint Admins and Developers - SharePoint ...
Sql Server & PowerShell
SharePoint Saturday Ottawa 2015 - Office 365 and PowerShell - A match made in...
Doctor Flow- Best practices Microsoft flow - Techorama 2019
Ad

More from Vlad Catrinescu (20)

PPTX
SharePoint Saturday Nashville: Microsoft 365 Certifications Overview
PDF
Deep dive into one drive known folder move
PDF
Microsoft 365 Certifications Overview
PPTX
SharePoint Fest Chicago Keynote - The foundation of your digital workplace is...
PPTX
SharePoint Fest Seattle - Three Must-Have Workflows with Microsoft Flow
PPTX
SharePoint Fest Seattle - Advanced PowerShell for Office 365
PDF
SharePoint Saturday Warsaw: Seek a Modern and Intelligent Foundation for your...
PDF
aOS Canadian Tour 2017 - Toronto- What do YOU get from SharePoint Hybrid?
PPTX
Tournee Canadienne aOS - Quebec - Qu'est-ce que VOUS obtenez d'un environneme...
PDF
aOS Canadian Tour 2017 - Ottawa - What do YOU get from SharePoint Hybrid?
PDF
Tournee Canadienne aOS - Montreal - Qu'est-ce que VOUS obtenez d'un environn...
PDF
SharePoint 2016 : C’est quoi les nouveautés?
PDF
Data Loss Prevention in SharePoint 2016 Webinar with Crow Canyon
PDF
What's new in SharePoint 2016 for IT Professionals Webinar with CrowCanyon
PDF
What's New in SharePoint 2016 for End Users Webinar with Intlock
PDF
Collab365: What's new in SharePoint 2016 for IT Pros
PDF
SQL 2014 Availability Groups for SharePoint
PDF
SharePoint Saturday Ottawa- Automate your Deployments with TFS and Build Server
PPTX
SharePoint Saturday Albany 2014 - The Fantastic 4 of Communication and Collab...
PPTX
Lync, Exchange, Sharepoint and Office Web Apps, the Fantastic 4 of Communi...
SharePoint Saturday Nashville: Microsoft 365 Certifications Overview
Deep dive into one drive known folder move
Microsoft 365 Certifications Overview
SharePoint Fest Chicago Keynote - The foundation of your digital workplace is...
SharePoint Fest Seattle - Three Must-Have Workflows with Microsoft Flow
SharePoint Fest Seattle - Advanced PowerShell for Office 365
SharePoint Saturday Warsaw: Seek a Modern and Intelligent Foundation for your...
aOS Canadian Tour 2017 - Toronto- What do YOU get from SharePoint Hybrid?
Tournee Canadienne aOS - Quebec - Qu'est-ce que VOUS obtenez d'un environneme...
aOS Canadian Tour 2017 - Ottawa - What do YOU get from SharePoint Hybrid?
Tournee Canadienne aOS - Montreal - Qu'est-ce que VOUS obtenez d'un environn...
SharePoint 2016 : C’est quoi les nouveautés?
Data Loss Prevention in SharePoint 2016 Webinar with Crow Canyon
What's new in SharePoint 2016 for IT Professionals Webinar with CrowCanyon
What's New in SharePoint 2016 for End Users Webinar with Intlock
Collab365: What's new in SharePoint 2016 for IT Pros
SQL 2014 Availability Groups for SharePoint
SharePoint Saturday Ottawa- Automate your Deployments with TFS and Build Server
SharePoint Saturday Albany 2014 - The Fantastic 4 of Communication and Collab...
Lync, Exchange, Sharepoint and Office Web Apps, the Fantastic 4 of Communi...
Ad

Recently uploaded (20)

PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Electronic commerce courselecture one. Pdf
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Approach and Philosophy of On baking technology
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Empathic Computing: Creating Shared Understanding
PDF
NewMind AI Weekly Chronicles - August'25 Week I
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Big Data Technologies - Introduction.pptx
PPT
Teaching material agriculture food technology
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
MIND Revenue Release Quarter 2 2025 Press Release
Electronic commerce courselecture one. Pdf
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Network Security Unit 5.pdf for BCA BBA.
Approach and Philosophy of On baking technology
“AI and Expert System Decision Support & Business Intelligence Systems”
Empathic Computing: Creating Shared Understanding
NewMind AI Weekly Chronicles - August'25 Week I
The AUB Centre for AI in Media Proposal.docx
Understanding_Digital_Forensics_Presentation.pptx
Spectral efficient network and resource selection model in 5G networks
Big Data Technologies - Introduction.pptx
Teaching material agriculture food technology
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Unlocking AI with Model Context Protocol (MCP)
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx

Collab365: PowerShell for Office 365