forked from jameswh3/MW-Toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNew-DemoProjectHubSites.ps1
More file actions
124 lines (109 loc) · 3.89 KB
/
Copy pathNew-DemoProjectHubSites.ps1
File metadata and controls
124 lines (109 loc) · 3.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# Requires: PnP.PowerShell module
# Install-Module -Name "PnP.PowerShell" -Scope CurrentUser
# Define site properties
$sites = @(
@{
Title = "Project Hub Site"
Url = "https://contoso.sharepoint.com/sites/projecthub"
Owner = "user1@contoso.com"
Description = "Central hub for all projects"
},
@{
Title = "NorthAm Regional Site"
Url = "https://contoso.sharepoint.com/sites/northamprojects"
Owner = "user2@contoso.com"
Description = "North America regional site for projects"
},
@{
Title = "LATAM Regional Site"
Url = "https://contoso.sharepoint.com/sites/latamprojects"
Owner = "user3@contoso.com"
Description = "Latin America regional site for projects"
},
@{
Title = "APAC Regional Site"
Url = "https://contoso.sharepoint.com/sites/apacprojects"
Owner = "user4@contoso.com"
Description = "Asia-Pacific regional site for projects"
},
@{
Title = "EMEA Regional Site"
Url = "https://contoso.sharepoint.com/sites/emeaprojects"
Owner = "user5@contoso.com"
Description = "Europe, Middle East, and Africa regional site for projects"
},
@{
Title = "Antarctica Regional Site"
Url = "https://contoso.sharepoint.com/sites/antarcticaprojects"
Owner = "user6@contoso.com"
Description = "Antarctica regional site for projects"
}
)
foreach ($site in $sites) {
Write-Host "Provisioning site: $($site.Title)"
New-PnPSite -Type CommunicationSite `
-Title $site.Title `
-Url $site.Url `
-Owner $site.Owner `
-Description $site.Description
}
foreach ($site in $sites) {
$hubSite = Register-PnPHubSite -Site $site.Url -ErrorAction Stop
Write-Host "Hub site registered: $($hubSite.Title) $($site.Url)" -ForegroundColor Green
}
# Associate each regional site with the Project Hub Site
$projectHubUrl = $sites[0].Url
foreach ($site in $sites[1..($sites.Count - 1)]) {
Write-Host "Associating $($site.Title) with Hub Site"
Add-PnPHubSiteAssociation -Site $site.Url -HubSite $projectHubUrl -ErrorAction Stop
}
# Create 100 project site collections and associate them with regional hubs
# Regional hub mapping
$regionalHubs = @{
"NorthAm" = $sites[1].Url
"EMEA" = $sites[4].Url
"LATAM" = $sites[2].Url
"APAC" = $sites[3].Url
"Antarctica" = $sites[5].Url
}
# Distribution: NorthAm=30, EMEA=25, LATAM=20, APAC=15, Antarctica=10
$distribution = @(
@{ Region = "NorthAm"; Count = 30 },
@{ Region = "EMEA"; Count = 25 },
@{ Region = "LATAM"; Count = 20 },
@{ Region = "APAC"; Count = 15 },
@{ Region = "Antarctica"; Count = 10 }
)
$projectSites = @()
$projectNumber = 1
foreach ($dist in $distribution) {
for ($i = 1; $i -le $dist.Count; $i++) {
$region = $dist.Region
$siteUrl = "https://contoso.sharepoint.com/sites/project$($projectNumber)"
$title = "Project $($projectNumber) Site"
$owner = "user1@contoso.com"
$description = "Project $($projectNumber) for $region region"
$projectSites += @{
Title = $title
Url = $siteUrl
Alias = "project$($projectNumber)"
Owner = $owner
Description = $description
Region = $region
}
$projectNumber++
}
}
foreach ($proj in $projectSites) {
Write-Host "Provisioning project site: $($proj.Title)"
New-PnPSite -Type TeamSite `
-Title $proj.Title `
-Alias $proj.Alias `
-Owner $proj.Owner `
-Description $proj.Description
}
foreach ($proj in $projectSites) {
$hubUrl = $regionalHubs[$proj.Region]
Write-Host "Associating $($proj.Title) with $($proj.Region) hub"
Add-PnPHubSiteAssociation -Site $proj.Url -HubSite $hubUrl -ErrorAction Stop
}