Skip to content

Commit 70391fb

Browse files
Merge pull request SharePoint#5390 from KoenZomers/patch-21
Fixed hub site creation page
2 parents b09f30c + 8bcc395 commit 70391fb

File tree

1 file changed

+22
-69
lines changed

1 file changed

+22
-69
lines changed

docs/features/hub-site/create-hub-site-with-powershell.md

Lines changed: 22 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -15,59 +15,39 @@ If you're a global or SharePoint admin in Office 365, you can convert any existi
1515
> [!NOTE]
1616
> To work with this example in SharePoint Online, we recommend that you use a developer tenant and not your production tenant. All of the following steps use a fictional tenant named "Contoso" that you can replace with your tenant name.
1717
18-
## Connect to SPO
18+
## Using PnP PowerShell
1919

20-
First, you need to connect to SharePoint Online by using PowerShell. The commands use both the [SharePoint Online Management Shell](https://www.microsoft.com/download/details.aspx?id=35588) (-SPO) and the [SharePoint PnP PowerShell Online module](https://www.powershellgallery.com/packages/SharePointPnPPowerShellOnline) (-PnP).
21-
22-
1. Start Windows PowerShell.
23-
24-
2. Run the [Connect-SPOService](https://docs.microsoft.com/powershell/module/sharepoint-online/connect-sposervice?view=sharepoint-ps) cmdlet to connect to SharePoint Online. Sign in with your global or SharePoint admin credentials:
25-
26-
```powershell
27-
Connect-SPOService -Url "https://<your tenant name>-admin.sharepoint.com"
28-
```
20+
The samples below can be performed using [PnP PowerShell](https://www.powershellgallery.com/packages/SharePointPnPPowerShellOnline).
2921

3022
> [!NOTE]
3123
> In the remainder of this exercise, **contoso** will be used as the tenant name. Continue to use your own tenant name in place of **contoso**.
3224
3325
## Create a new hub site
3426

35-
Next, create the marketing site that will serve as a hub site that other sites can associate with. The intent is that any sites that are marketing-oriented will be part of the hub site. This applies common navigation and branding across the associated sites, enables team members to search across all the sites associated with the single hub site, and takes advantage of other hub site features.
27+
First, we will create the marketing site that will serve as a hub site that other sites can associate with. The intent is that any sites that are marketing-oriented will be part of the hub site. This applies common navigation and branding across the associated sites, enables team members to search across all the sites associated with the single hub site, and takes advantage of other hub site features.
3628

37-
1. Create the site using the [New-PnPSite](https://docs.microsoft.com/powershell/module/sharepoint-pnp/new-pnpsite) cmdlet:
29+
1. Connect to the SharePoint Online Admin center using:
3830

3931
```powershell
40-
Connect-PnPOnline -SPOManagementShell
41-
New-PnPSite -Type TeamSite
42-
-title "Contoso marketing division"
43-
-alias "marketing"
44-
-Description "Main site for collaboration for marketing teams at Contoso"
32+
Connect-PnPOnline -Url https://contoso-admin.sharepoint.com -UseWebLogin
4533
```
4634

47-
The `-SPOManagementShell` parameter allows you to reuse the credentials you signed in with by using the Connect-SPOService cmdlet.
35+
2. Create the site to be used as a hub site using the [New-PnPSite](https://docs.microsoft.com/powershell/module/sharepoint-pnp/new-pnpsite) cmdlet:
36+
37+
```powershell
38+
New-PnPSite -Type TeamSite -Title "Contoso marketing division" -Alias "marketing" -Description "Main site for collaboration for marketing teams at Contoso"
39+
```
4840

4941
The cmdlet returns the URL of the new site similar to the following:
5042

5143
```
5244
https://contoso.sharepoint.com/sites/marketing
5345
```
5446

55-
2. Register the new marketing site as a hub site by using the [Register-SPOHubSite](https://docs.microsoft.com/powershell/module/sharepoint-online/register-spohubsite?view=sharepoint-ps) cmdlet:
47+
3. Register the new marketing site as a hub site by using the [Register-PnPHubSite](https://docs.microsoft.com/powershell/module/sharepoint-online/register-spohubsite?view=sharepoint-ps) cmdlet:
5648

5749
```powershell
58-
Register-SPOHubSite -Site https://contoso.sharepoint.com/sites/marketing
59-
```
60-
61-
You will see output similar to the following:
62-
63-
```
64-
ID : bf0245ee-6bff-48a5-968f-0f155e2b7bbc
65-
Title : Contoso marketing division
66-
SiteId : bf0245ee-6bff-48a5-968f-0f155e2b7bbc
67-
SiteUrl : https://contoso.sharepoint.com/sites/marketing
68-
LogoUrl :
69-
Description :
70-
Permissions :
50+
Register-PnPHubSite -Site https://contoso.sharepoint.com/sites/marketing
7151
```
7252

7353
## Set properties and permissions on the hub site
@@ -78,60 +58,33 @@ The hub site doesn't have a logo or description yet. We also want to constrain i
7858

7959
1. Upload a logo image for the site by going to `https://contoso.sharepoint.com/sites/marketing/SiteAssets` and uploading any image you like. Make a note of the image file name.
8060

81-
2. Use the [Set-SPOHubSite](https://docs.microsoft.com/powershell/module/sharepoint-online/set-spohubsite?view=sharepoint-ps) cmdlet to set the logo and description. In place of `mylogo.jpg`, specify the name of the image that you uploaded:
61+
2. Use the [Set-PnPHubSite](https://docs.microsoft.com/powershell/module/sharepoint-pnp/set-pnphubsite) cmdlet to set the logo and description. In place of `mylogo.jpg`, specify the name of the image that you uploaded:
8262

8363
```powershell
84-
Set-SPOHubSite
64+
Set-PnPHubSite
8565
-Identity https://contoso.sharepoint.com/sites/marketing
8666
-LogoUrl https://contoso.sharepoint.com/marketing/SiteAssets/mylogo.jpg
8767
-Description "Main hub site for collaboration on marketing activities across Contoso"
8868
```
8969

90-
You will see output similar to the following:
91-
92-
```
93-
ID : bf0245ee-6bff-48a5-968f-0f155e2b7bbc
94-
Title : Contoso marketing division
95-
SiteId : bf0245ee-6bff-48a5-968f-0f155e2b7bbc
96-
SiteUrl : https://contoso.sharepoint.com/sites/marketing
97-
LogoUrl : https://contoso.sharepoint.com/sites/marketing/SiteAssets/mylogo.jpg
98-
Description : Main hub site for collaboration on marketing activities across Contoso
99-
Permissions :
100-
```
101-
10270
### Set permissions
10371

104-
Now we will restrict access so that only the user `nestorw@contoso` can make changes to the hub site associations.
72+
Now we will restrict access so that only the user `nestorw@contoso.com` can make changes to the hub site associations.
10573

106-
- Run the [Grant-SPOHubSiteRights](https://docs.microsoft.com/powershell/module/sharepoint-online/grant-spohubsiterights?view=sharepoint-ps) cmdlet to grant a user rights to the marketing hub site. We'll use `nestorw@contoso` in this example, but you can use any valid user on your tenant (you can specify multiple users by separating them with a comma):
74+
- Run the [Grant-PnPHubSiteRights](https://docs.microsoft.com/powershell/module/sharepoint-pnp/grant-pnphubsiterights) cmdlet to grant a user rights to the marketing hub site. We'll use `nestorw@contoso` in this example, but you can use any valid user on your tenant (you can specify multiple users by separating them with a comma):
10775

10876
```powershell
109-
Grant-SPOHubSiteRights -Identity https://contoso.sharepoint.com/sites/marketing -Principals "nestorw@contoso" -Rights Join
110-
```
111-
112-
You will see output similar to the following:
113-
114-
```
115-
ID : bf0245ee-6bff-48a5-968f-0f155e2b7bbc
116-
Title : Contoso marketing division
117-
SiteId : bf0245ee-6bff-48a5-968f-0f155e2b7bbc
118-
SiteUrl : https://contoso.sharepoint.com/sites/marketing
119-
LogoUrl : https://contoso.sharepoint.com/sites/marketing/SiteAssets/mylogo.jpg
120-
Description : Main hub site for collaboration on marketing activities across Contoso
121-
Permissions : {0#.f|membership|[email protected]}
77+
Grant-PnPHubSiteRights -Identity https://contoso.sharepoint.com/sites/marketing -Principals "nestorw@contoso" -Rights Join
12278
```
12379

12480
## Create and associate a new site
12581

12682
The final step is to create the site we want to associate with the hub. You can repeat these steps for as many sites as you want to join to the hub.
12783

128-
1. Provision the site by using the [New-PnPSite](https://docs.microsoft.com/powershell/module/sharepoint-pnp/new-pnpsite?view=sharepoint-ps) cmdlet:
84+
1. Provision the site by using the [New-PnPSite](https://docs.microsoft.com/powershell/module/sharepoint-pnp/new-pnpsite) cmdlet:
12985

13086
```powershell
131-
New-PnPSite -Type TeamSite
132-
-title "Online advertising team"
133-
-alias "online-advertising"
134-
-Description "For collaboration on online advertising resources"
87+
New-PnPSite -Type TeamSite -Title "Online advertising team" -Alias "online-advertising" -Description "For collaboration on online advertising resources"
13588
```
13689

13790
The cmdlet returns the URL of the new site similar to the following:
@@ -140,10 +93,10 @@ The final step is to create the site we want to associate with the hub. You can
14093
https://contoso.sharepoint.com/sites/online-advertising
14194
```
14295

143-
2. Associate this site with the hub site by using the [Add-SPOHubSiteAssociation](https://docs.microsoft.com/powershell/module/sharepoint-online/add-spohubsiteassociation?view=sharepoint-ps) cmdlet:
96+
2. Associate this site with the hub site by using the [Add-PnPHubSiteAssociation](https://docs.microsoft.com/powershell/module/sharepoint-pnp/add-pnphubsiteassociation) cmdlet:
14497

14598
```powershell
146-
Add-SPOHubSiteAssociation
99+
Add-PnPHubSiteAssociation
147100
-Site https://contoso.sharepoint.com/sites/online-advertising
148101
-HubSite https://contoso.sharepoint.com/sites/marketing
149102
```
@@ -152,7 +105,7 @@ The final step is to create the site we want to associate with the hub. You can
152105

153106
To confirm, you can either:
154107

155-
- Run the [Get-SPOHubSite](https://docs.microsoft.com/powershell/module/sharepoint-online/get-spohubsite?view=sharepoint-ps) cmdlet.
108+
- Run the [Get-PnPHubSite](https://docs.microsoft.com/powershell/module/sharepoint-pnp/get-pnphubsite) cmdlet.
156109

157110
- Sign in to SharePoint Online and view the hub site directly at `https://contoso.sharepoint.com/sites/marketing`.
158111

0 commit comments

Comments
 (0)