-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathGet Sharepoint Online Template List.ps1
31 lines (26 loc) · 1.19 KB
/
Get Sharepoint Online Template List.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function get-SPOnlineListTemplates {
#variables that needs to be set before starting the script
$siteURL = "https://domain.sharepoint.com/"
$adminUrl = "https://domain-admin.sharepoint.com"
$userName = "[email protected]"
# Let the user fill in their password in the PowerShell window
$password = Read-Host "Please enter the password for $($userName)" -AsSecureString
# set SharePoint Online credentials
$SPOCredentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($userName, $password)
# Creating client context object
$context = New-Object Microsoft.SharePoint.Client.ClientContext($siteURL)
$context.credentials = $SPOCredentials
$listTemplates = $context.web.listtemplates
$context.load($listTemplates)
#send the request containing all operations to the server
try{
$context.executeQuery()
write-host "info: Loaded list templates" -foregroundcolor green
}
catch{
write-host "info: $($_.Exception.Message)" -foregroundcolor red
}
#List available templates
$listTemplates | select baseType, Description, ListTemplateTypeKind | ft –wrap
}
get-SPOnlineListTemplates