Post

Get SharePoint Online web templates with PowerShell
I already have a couple of posts where I can take information out of SharePoint Online but I didn’t had any posts to put information into SharePoint Online. I’ve came up with a case where you for example want to setup a new site without using a template. The posts will contain stand-alone scripts which you […]

I already have a couple of posts where I can take information out of SharePoint Online but I didn’t had any posts to put information into SharePoint Online. I’ve came up with a case where you for example want to setup a new site without using a template. The posts will contain stand-alone scripts which you can combine. I’ve created these scripts to learn more about using PowerShell for SharePoint Online so let me know if you have any tips or if this was helpful.

The next couple of posts will consist of 10 parts. We will be collecting all available web templates in part 1 so we can use this to create a new site in part 2. In part 3 we will be creating a web for the newly created site. We then want to create a couple of site columns in part 4 which we will combine to a content type in part 5. This content type will be added (part 8) to our newly created document library in part 7 using a list template from part 6. After everything is set we will be setting the view in part 9 for this list to show the added columns we got from adding the content type. We only want to set permissions for myself so I’ll will be breaking the inheritance and setting permissions in part 10.

Get SharePoint Online web Templates

We are going to start with a simple script that will retrieve the available web templates. Microsoft can add or remove templates from SharePoint Online in the future. This script will be not be using CSOM as we have a SPO command to retrieve this information. We will first start by opening the SharePoint Online Management Shell as administrator which can be downloaded at https://www.microsoft.com/en-us/download/details.aspx?id=35588.

image

You will need to change the first variables to match your Office 365 tenant and copy this bit to PowerShell.

function get-SPOnlineWebTemplates {
 #variables that needs to be set before starting the script
 $adminUrl = "https://spfire-admin.sharepoint.com"
 $userName = "mpadmin@spfire.onmicrosoft.com"
 $password = Read-Host "Please enter the password for $($userName)" –AsSecureString
 
 #set credentials for SharePoint Online
 $credentials = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $userName, $password
 
 #connect to SharePoint Online
 Connect-SPOService -Url $adminUrl -Credential $credentials
 
 get-spoWebTemplate
}
get-SPOnlineWebTemplates

image

You will be asked to enter the password and press enter

image

We will be using the Name in our next post to create a team site

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Archive