@@ -358,6 +358,23 @@ function Invoke-AADAssessmentDataCollection {
358358 Remove-Item - Path (Join-Path $OutputDirectoryAAD " *" ) - Include " *Data.csv" - ErrorAction Ignore
359359 }
360360
361+ # ## Package Output
362+ if (! $SkipPackaging ) {
363+ Write-AppInsightsTrace (" {0} - Package Output" -f $MyInvocation.MyCommand.Name ) - SeverityLevel Verbose - IncludeProcessStatistics - OrderedProperties (Get-ReferencedIdCacheDetail $ReferencedIdCache )
364+ Write-Progress - Id 0 - Activity (' Microsoft Azure AD Assessment - {0}' -f $InitialTenantDomain ) - Status ' Packaging Data' - PercentComplete 95
365+
366+ # ## Remove pre existing package (zip) if it exists
367+ if (Test-Path - Path $PackagePath ) { Remove-Item $PackagePath - Force }
368+
369+ # ## Package Output
370+ # Compress-Archive (Join-Path $OutputDirectoryData '\*') -DestinationPath $PackagePath -Force -ErrorAction Stop
371+ [System.IO.Compression.ZipFile ]::CreateFromDirectory($OutputDirectoryData , $PackagePath )
372+ $PackageFileInfo = Get-Item $PackagePath
373+ Write-AppInsightsTrace (" {0} - Package Complete" -f $MyInvocation.MyCommand.Name ) - SeverityLevel Verbose - IncludeProcessStatistics - OrderedProperties ((Get-ReferencedIdCacheDetail $ReferencedIdCache ) + [ordered ]@ { PackageSize = Format-NumberWithUnit $PackageFileInfo.Length ' B' ; PackageSizeInBytes = $PackageFileInfo.Length })
374+
375+ Remove-Item $OutputDirectoryData - Recurse - Force
376+ }
377+
361378 # ## Complete
362379 Write-Progress - Id 0 - Activity (' Microsoft Azure AD Assessment - {0}' -f $InitialTenantDomain ) - Completed
363380
@@ -372,21 +389,6 @@ function Invoke-AADAssessmentDataCollection {
372389 # Stop-Transcript
373390 # $Error | Select-Object -Last ($Error.Count - $ErrorStartCount) | Export-Clixml -Path (Join-Path $OutputDirectoryData "PowerShell_errors.xml") -Depth 10
374391
375- if (! $SkipPackaging ) {
376- Write-AppInsightsTrace (" {0} - Package" -f $MyInvocation.MyCommand.Name ) - SeverityLevel Verbose - IncludeProcessStatistics - OrderedProperties (Get-ReferencedIdCacheDetail $ReferencedIdCache )
377-
378- # ## Remove pre existing package (zip) if it exists
379- if (Test-Path - Path $PackagePath ) {
380- Remove-Item $PackagePath - Force
381- }
382-
383- # ## Package Output
384- # Compress-Archive (Join-Path $OutputDirectoryData '\*') -DestinationPath $PackagePath -Force -ErrorAction Stop
385- [System.IO.Compression.ZipFile ]::CreateFromDirectory($OutputDirectoryData , $PackagePath )
386-
387- Remove-Item $OutputDirectoryData - Recurse - Force
388- }
389-
390392 # ## Open Directory
391393 try {
392394 Invoke-Item $OutputDirectory - ErrorAction SilentlyContinue
0 commit comments