Powershell - How to create a sub-site in Sharepoint Online

Asked

Viewed 442 times

4

I have a website and I need to create sub-sites dynamically because they are many customers and I tried to use powershell for this, but I can only create a Collection site. Example:

new-SPOSite -url httl://url.sharepoint.com/douglas -owner [email protected]

This he creates my site all right but need to create sub-sites, example:

httl://url.sharepoint.com/douglas/cliente1
httl://url.sharepoint.com/douglas/cliente2
httl://url.sharepoint.com/douglas/cliente3
httl://url.sharepoint.com/douglas/cliente4

That way it doesn’t work and I can’t find an explanation or a way to do it. Creating manually is out of the question as there are many customers and more and more requests come for it.

I haven’t found a solution even on google. Someone can help?

Thank you.

3 answers

2

  • 1

    +1. Now, as far as I know, Powershell for Sharepoint Online is a work in progress. I hope that in the future this will be possible.

1

Two things:

  • If you can let your customers create websites, it might make things easier for you. Just have the permission to Manage Hierarchy in the collection of websites. Then in the settings of the root site they can create the children (in Site Administration -> Sites and Workspaces).

Editing: After seeing the response from Sunstreaker, I realized that you are using a command to create collection of websites. To create Subsites the correct command is New-SPWeb.

  • If the goal is for websites to be created without the staff having any access to the root of the collection, you can create a script that accepts parameters.

Create an extension file .ps1 with something like:

$endereco = $args[0]
$titulo = $args[1]

new-SPWeb -url $endereco -name $titulo

Hence you call it that, from the prompt, being in the folder where the file is (assuming the file is called foo.ps1):

powershell.exe foo.ps1 "httl://url.sharepoint.com/douglas/clienteBar" "Site do Bar"

Or you can make a program in . NET in two minutes that keeps generating and running these calls ;)

  • 2

    Hi Renan. I ended up responding in Sunstreaker’s response and tb serves for what you said. I don’t know how to proceed since the Shell that connects in Sharepoint Online is not the same.

  • @Douglas should only be the case of calling the executable corresponding to the Sharepoint Online shell, no?

  • 1

    Actually not because the Shell specific for Sharepoint Online does not have many cmdlets, just basic for management... what I’m seeing now is doing something with Rest by powershell... I thought it could be easier than this.

0

It turned out that by powershell I could not myself and switched to script where I can create as many and the way I need each Subsite. Thanks for the answers.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.