@@ -58,8 +58,11 @@ function Invoke-CIPPSharePointTemplateDeploy {
5858 $SiteIndex = -1
5959 foreach ($SiteTemplate in $TemplateData.siteTemplates ) {
6060 $SiteIndex ++
61+ # Step counter for this site: prerequisites, create, site permissions, then one step
62+ # per library. Shown as 'Step x of y' in the live progress messages.
63+ $TotalSteps = 3 + @ ($SiteTemplate.libraries ).Count
6164 try {
62- Update-DeployStep - Index $SiteIndex - Status ' running' - Message ' Checking prerequisites'
65+ Update-DeployStep - Index $SiteIndex - Status ' running' - Message " Step 1 of ${TotalSteps} : Checking prerequisites"
6366 # Skip if exists: leave pre-existing sites/teams completely untouched — no
6467 # libraries or permission changes are applied to anything this run didn't create.
6568 if ($SkipIfExists ) {
@@ -89,12 +92,12 @@ function Invoke-CIPPSharePointTemplateDeploy {
8992 # Create the container first: a full Team (Teams API) so all Teams functionality
9093 # stays intact, or a plain SharePoint site otherwise.
9194 if ($TemplateData.createAsTeams -eq $true ) {
92- Update-DeployStep - Index $SiteIndex - Status ' running' - Message ' Creating Team and waiting for its SharePoint site'
95+ Update-DeployStep - Index $SiteIndex - Status ' running' - Message " Step 2 of ${TotalSteps} : Creating Team and waiting for its SharePoint site"
9396 $Team = New-CIPPTeam - DisplayName $SiteTemplate.displayName - Description ($SiteTemplate.description ?? ' ' ) - Owner $SiteOwner - TenantFilter $TenantFilter - Headers $Headers - APIName $APIName
9497 $SiteUrl = $Team.SiteUrl
9598 $Results.Add (" [$TenantFilter ] Created Team '$ ( $SiteTemplate.displayName ) ' with site $SiteUrl " )
9699 } else {
97- Update-DeployStep - Index $SiteIndex - Status ' running' - Message ' Creating SharePoint site'
100+ Update-DeployStep - Index $SiteIndex - Status ' running' - Message " Step 2 of ${TotalSteps} : Creating SharePoint site"
98101 $null = New-CIPPSharepointSite - SiteName $SiteTemplate.displayName - SiteDescription ($SiteTemplate.description ?? $SiteTemplate.displayName ) - SiteOwner $SiteOwner - TemplateName ' Team' - TenantFilter $TenantFilter - Headers $Headers - APIName $APIName
99102 $SharePointInfo = Get-SharePointAdminLink - Public $false - tenantFilter $TenantFilter
100103 $SitePath = $SiteTemplate.displayName -replace ' ' -replace ' [^A-Za-z0-9-]'
@@ -103,7 +106,7 @@ function Invoke-CIPPSharePointTemplateDeploy {
103106 }
104107
105108 # Root-level permissions, grouped per permission level.
106- Update-DeployStep - Index $SiteIndex - Status ' running' - Message ' Applying site permissions'
109+ Update-DeployStep - Index $SiteIndex - Status ' running' - Message " Step 3 of ${TotalSteps} : Applying site permissions"
107110 $RootPermGroups = @ ($SiteTemplate.permissions ) | Group-Object - Property permissionLevel
108111 foreach ($PermGroup in $RootPermGroups ) {
109112 $GroupNames = @ ($PermGroup.Group | ForEach-Object { & $GetPrincipalName $_.principal }) | Where-Object { $_ }
@@ -116,9 +119,11 @@ function Invoke-CIPPSharePointTemplateDeploy {
116119 }
117120
118121 # Then the document libraries via the SharePoint module.
122+ $LibraryStep = 3
119123 foreach ($Library in $SiteTemplate.libraries ) {
124+ $LibraryStep ++
120125 try {
121- Update-DeployStep - Index $SiteIndex - Status ' running' - Message " Creating library '$ ( $Library.name ) '"
126+ Update-DeployStep - Index $SiteIndex - Status ' running' - Message " Step $LibraryStep of ${TotalSteps} : Creating library '$ ( $Library.name ) '"
122127 $NewLibrary = New-CIPPSharePointLibrary - SiteUrl $SiteUrl - LibraryName $Library.name - Description ($Library.description ?? ' ' ) - TenantFilter $TenantFilter - Headers $Headers - APIName $APIName
123128 $Results.Add (" [$TenantFilter ] $ ( $SiteTemplate.displayName ) : library '$ ( $Library.name ) ' $ ( $NewLibrary.Created ? ' created' : ' already existed' ) " )
124129
@@ -136,7 +141,7 @@ function Invoke-CIPPSharePointTemplateDeploy {
136141 $Results.Add (" [$TenantFilter ] $ ( $SiteTemplate.displayName ) : library '$ ( $Library.name ) ' failed - $ ( $_.Exception.Message ) " )
137142 }
138143 }
139- Update-DeployStep - Index $SiteIndex - Status ' succeeded' - Message " Deployed at $SiteUrl "
144+ Update-DeployStep - Index $SiteIndex - Status ' succeeded' - Message " Completed all $TotalSteps steps. Deployed at $SiteUrl "
140145 } catch {
141146 $Results.Add (" [$TenantFilter ] Failed to deploy '$ ( $SiteTemplate.displayName ) ': $ ( $_.Exception.Message ) " )
142147 Update-DeployStep - Index $SiteIndex - Status ' failed' - Message $_.Exception.Message
0 commit comments