Skip to content

Commit be4ca32

Browse files
committed
Extends the SharePoint docs on creating modern team sites using the Office365 CLI
1 parent 0e067b4 commit be4ca32

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

docs/solution-guidance/modern-experience-customizations-provisioning-sites.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,29 @@ $web.WebTemplate + "#" + $web.Configuration
108108
```
109109

110110
### Provisioning an Office 365 group programmatically
111+
#### Provisioning a "modern" team site using the Office 365 CLI
112+
113+
Alternatively, the [Office 365 CLI](https://sharepoint.github.io/office365-cli/?utm_source=msft_docs&utm_medium=page&utm_campaign=Provisioning+modern+team+sites+programmatically) can be used to create "modern" sites. The Office 365 CLI is a cross-platform command line interface that can be used on any platform, including Windows, MacOS and Linux.
114+
115+
The following bash script will create a "modern" team site and then return the actual SharePoint site URL for further manipulation. Once you have access to the URL of the created site, you can use it to automate other operations on the created site.
116+
117+
```bash
118+
#!/usr/bin/env bash
119+
# Connect to SharePoint Online
120+
# This command will prompt a sign-in confirmation message to authenticate
121+
o365 spo connect https://[tenant].sharepoint.com/
122+
123+
# Create the new "modern" team site
124+
siteUrl=$(o365 spo site add --type TeamSite --title 'displayName' --alias 'mymodernteamsite' --description 'description' --isPublic --classification 'classification')
125+
126+
# Display the modern site url
127+
echo $siteUrl
128+
129+
# Since the Office 365 CLI is connected to SharePoint Online we can do any operations.
130+
# As example, we can list all the properties from the site property bag:
131+
o365 spo propertybag list -u $siteUrl
132+
```
133+
111134

112135
"Modern" team sites can be created programmatically by creating an [Office 365 group](https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/resources/group) using the Microsoft Graph, too. In fact, when you create an Office 365 group a "modern" team site is automatically provisioned for the group. The "modern" team site URI will be based upon the _mailNickname_ parameter of the Office 365 group and has the following default structure.
113136

@@ -169,6 +192,23 @@ Connect-PnPOnline -Url https://contoso-admin.sharepoint.com
169192
New-PnPSite -Type Team -Title "Awesome Group" -Description "Awesome Group" -Alias "awesome-group"
170193
```
171194

195+
#### Provisioning an Office 365 Group using the Office 365 CLI
196+
197+
Alternatively, the [Office 365 CLI](https://sharepoint.github.io/office365-cli/cmd/graph/o365group/o365group-add/?utm_source=msft_docs&utm_medium=page&utm_campaign=Provisioning+modern+team+sites+programmatically) can be used to create an Office 365 Group, which will let you easily authenticate with the Microsoft Graph and then create the new group.
198+
The example below shows how it can be done using the [Office 365 CLI immersive mode](https://sharepoint.github.io/office365-cli/user-guide/using-cli/#start-the-cli-in-the-immersive-mode?utm_source=msft_docs&utm_medium=page&utm_campaign=Provisioning+modern+team+sites+programmatically).
199+
200+
```bash
201+
# Use the Office 365 CLI immersive mode by typing o365 in the terminal
202+
# Connect to Microsoft Graph using the Office 365 CLI
203+
# This command will prompt a sign-in confirmation message to authenticate
204+
graph connect
205+
206+
# Create an Office 365 Group
207+
# The newly created SharePoint site for that group will has URL
208+
# https://[tenant].sharepoint.com/sites/awesome-group
209+
graph o365group add --displayName 'Awesome Group' --description 'Awesome Group' --mailNickname awesome-group
210+
```
211+
172212
> [!NOTE]
173213
> There is currently no support to provision "modern" team sites using [SharePoint Online Management Shell](https://www.microsoft.com/en-us/download/details.aspx?id=35588).
174214
@@ -244,6 +284,27 @@ Execute-PnPQuery
244284
$web.Title
245285
```
246286

287+
#### Provisioning a "modern" communication site using the Office 365 CLI
288+
289+
Alternatively, the [Office 365 CLI](https://sharepoint.github.io/office365-cli/cmd/spo/site/site-add/?utm_source=msft_docs&utm_medium=page&utm_campaign=Provisioning+modern+team+sites+programmatically) can be used to create "modern" Communication site. The following bash script will create the site and then return the actual SharePoint site URL for further manipulation. Once you have access to the URL you can use it to automate other operations on the created site.
290+
291+
```bash
292+
#!/usr/bin/env bash
293+
# Connect to SharePoint Online
294+
# This command will prompt a sign-in confirmation message to authenticate
295+
o365 spo connect https://[tenant].sharepoint.com/
296+
297+
# Create the new "modern" communication site
298+
siteUrl=$(o365 spo site add --type CommunicationSite --url https://[tenant].sharepoint.com/sites/mymoderncommunicationsite --title displayName --description description --classification classification)
299+
300+
# Display the modern site url
301+
echo $siteUrl
302+
303+
# Since the Office 365 CLI is connected to SharePoint Online we can do any operations.
304+
# As example, we can list all the properties from the site property bag:
305+
o365 spo propertybag list -u $siteUrl
306+
```
307+
247308
## Additional Considerations
248309

249310
### Sub sites use "classic" templates

0 commit comments

Comments
 (0)