You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/features/hub-site/create-hub-site-with-powershell.md
+22-69Lines changed: 22 additions & 69 deletions
Original file line number
Diff line number
Diff line change
@@ -15,59 +15,39 @@ If you're a global or SharePoint admin in Office 365, you can convert any existi
15
15
> [!NOTE]
16
16
> 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.
17
17
18
-
## Connect to SPO
18
+
## Using PnP PowerShell
19
19
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:
The samples below can be performed using [PnP PowerShell](https://www.powershellgallery.com/packages/SharePointPnPPowerShellOnline).
29
21
30
22
> [!NOTE]
31
23
> 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**.
32
24
33
25
## Create a new hub site
34
26
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.
36
28
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:
38
30
39
31
```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"
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
+
```
48
40
49
41
The cmdlet returns the URL of the new site similar to the following:
50
42
51
43
```
52
44
https://contoso.sharepoint.com/sites/marketing
53
45
```
54
46
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:
@@ -78,60 +58,33 @@ The hub site doesn't have a logo or description yet. We also want to constrain i
78
58
79
59
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.
80
60
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:
Description : Main hub site for collaboration on marketing activities across Contoso
99
-
Permissions :
100
-
```
101
-
102
70
### Set permissions
103
71
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.
105
73
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):
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:
0 commit comments