Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Microsoft SharePoint Online

Administrator Class
Lab J: PowerShell Scripts

Copyright © Combined Knowledge Ltd. All rights reserved. No part of this manual may be reproduced in any form or
by any method without the expressed, written consent of Combined Knowledge.

Please call 44-1455-200-520 for more information.

V 2.3
Lab J: PowerShell Scripts

Table of Content
TABLE OF CONTENT....................................................................................................................................................... 2

POWERSHELL SCRIPTS .................................................................................................................................................. 3

© Combined Knowledge LTD All rights reserved. Reproduction strictly prohibited.

Page 0 - 2
Lab J: PowerShell Scripts

PowerShell Scripts
For ease of access, we have amalgamated the PowerShell scripts used throughout this manual
for your convenience. They are listed in the order that they were used, broken down by the lab
and exercise they were used in and the page for context.

Lab Ex Page Command


A 3 13 install-module MSOnline
A 3 13 Import-Module MSOnline
Connect-MsolService
Get-MsolUser
A 4 14 Connect-SPOService –Url https://CKXXXXX-admin.sharepoint.com
A 4 15 get-spowebtemplate
A 5 16 Import-Module MSOnline
Connect-msolservice
A 5 17 Get-Msoluser
A 5 17 New-MsolUser –UserPrincipalName pete@CKXXXX.onmicrosoft.com –
DisplayName “Pete Coventry” –FirstName “Pete” –LastName “Coventry” –
Password ‘SpAdmin365’ -ForceChangePassword $false –UsageLocation
“GB”
A 5 18 Set-MsolUserLicense -UserPrincipalName pete@CKXXXX.onmicrosoft.com
–AddLicenses “CKXXXX:ENTERPRISEPREMIUM”
B 3 27 Connect-SPOService –Url https://CKXXXXX-admin.sharepoint.com
B 3 27 New-SPOSite -Url https://CKXXXX.sharepoint.com/sites/hr -title "HR
Home" -Owner steve@CKXXXX.onmicrosoft.com -storagequota 1024
-Template STS#0
B 3 27 Get-SPOSite
B 3 27 install-module -name PnP.PowerShell
B 3 28 Connect-PnPOnline -url https://CKXXXX-admin.sharepoint.com/ -
Interactive
B 3 28 New-PnPSite -Type TeamSite -Title 'Team CK' -Alias TeamCK
B 3 29 Set-SPOUser -site https://CKXXXX.sharepoint.com/sites/hr -LoginName
shannen@CKXXXX.onmicrosoft.com -IsSiteCollectionAdmin $True
B 3 29 Get-SPOUser -Site https://CKXXXX.sharepoint.com/sites/hr | where
{$_.IsSiteAdmin}
B 3 29 $spoSites=Get-SPOSite | Select *
B 3 29 foreach($spoSite in $spoSites)

B 3 29 {
© Combined Knowledge LTD All rights reserved. Reproduction strictly prohibited.

Page 0 - 3
Lab J: PowerShell Scripts

Write-Host "Admins for " $spoSite.Url -foregroundcolor Yellow


Get-SPOUser -Site $spoSite.Url | where {$_.IsSiteAdmin}
Write-Host
}
B 5 35 Connect-SPOService –Url https://CKXXXX-admin.sharepoint.com
B 5 38 $themepalette =
@{
"themePrimary" = "#e2b700";
"themeLighterAlt" = "#fefcf4";
"themeLighter" = "#fbf3d2";
"themeLight" = "#f7e9ad";
"themeTertiary" = "#eed45f";
"themeSecondary" = "#e6c11c";
"themeDarkAlt" = "#cca700";
"themeDark" = "#ac8d00";
"themeDarker" = "#7f6800";
"neutralLighterAlt" = "#faf9f8";
"neutralLighter" = "#f3f2f1";
"neutralLight" = "#edebe9";
"neutralQuaternaryAlt" = "#e1dfdd";
"neutralQuaternary" = "#d0d0d0";
"neutralTertiaryAlt" = "#c8c6c4";
"neutralTertiary" = "#c2c2c2";
"neutralSecondary" = "#858585";
"neutralPrimaryAlt" = "#4b4b4b";
"neutralPrimary" = "#333333";
"neutralDark" = "#272727";
"black" = "#1d1d1d";
"white" = "#ffffff";
}
Add-SPOTheme -Name "House Rules" -Palette $themepalette -IsInverted
$false

B 6 42 Set-SPOSite -identity https://CKXXXX.sharepoint.com/sites/intranet -


StorageQuota 15000 -StorageQuotaWarningLevel 13000
B 6 43 $spoSites=Get-SPOSite | Select *
B 6 43 foreach($spoSite in $spoSites)
B 6 43 {
Write-Host "Changing Quota for " $spoSite.Url -foregroundcolor Yellow
Set-SPOSite -identity $spoSite.URL -StorageQuota 12500 -
StorageQuotaWarningLevel 11000
Write-Host
}

© Combined Knowledge LTD All rights reserved. Reproduction strictly prohibited.

Page 0 - 4
Lab J: PowerShell Scripts

B 8 54 Remove-SPODeletedSite https://CKXXXX.sharepoint.com/sites/ProjectSite
B 10 60 Connect-SPOService -Url https://CKXXXX-admin.sharepoint.com
B 10 60 Set-SPOhomesite -homesiteurl
https://CKXXXX.sharepoint.com/sites/globalnews

© Combined Knowledge LTD All rights reserved. Reproduction strictly prohibited.

Page 0 - 5
Lab J: PowerShell Scripts

© Combined Knowledge LTD All rights reserved. Reproduction strictly prohibited.

Page 0 - 6

You might also like