@@ -77,10 +77,10 @@ function Test-Assessment-25376 {
7777 $profileState = ' Not found'
7878 $profileName = ' N/A'
7979 if ($m365Profile -and $m365Profile.Count -gt 0 ) {
80- $profile = $m365Profile | Select-Object - First 1
81- $profileName = $profile .name
82- $profileState = $profile .state
83- $profileEnabled = ($profile .state -eq ' enabled' )
80+ $m365ProfileData = $m365Profile | Select-Object - First 1
81+ $profileName = $m365ProfileData .name
82+ $profileState = $m365ProfileData .state
83+ $profileEnabled = ($m365ProfileData .state -eq ' enabled' )
8484 }
8585
8686 # Extract M365 transaction data
@@ -139,65 +139,73 @@ function Test-Assessment-25376 {
139139 # endregion Assessment Logic
140140
141141 # region Report Generation
142- $mdInfo = [ System.Text.StringBuilder ]::new()
142+ $mdInfo = ' '
143143
144144 # Summary Section
145- [void ]$mdInfo.AppendLine (" `n ## Summary`n " )
146- [void ]$mdInfo.AppendLine (" | Metric | Value |" )
147- [void ]$mdInfo.AppendLine (" | :--- | ---: |" )
148- [void ]$mdInfo.AppendLine (" | Profile Enabled | $ ( if ($profileEnabled ) { ' ✅ Yes' } else { ' ❌ No' }) |" )
149- [void ]$mdInfo.AppendLine (" | M365 Transactions (7 days) | $ ( $m365TotalCount.ToString (' N0' )) |" )
150- [void ]$mdInfo.AppendLine (" | M365 Blocked Transactions | $ ( $m365BlockedCount.ToString (' N0' )) |" )
151- [void ]$mdInfo.AppendLine (" | Active Devices | $activeDeviceCount |" )
152- [void ]$mdInfo.AppendLine (" | Total Devices | $totalDeviceCount |`n " )
145+ $mdInfo += " `n ## Summary`n`n "
146+ $mdInfo += " | Metric | Value |`n "
147+ $mdInfo += " | :--- | ---: |`n "
148+ $mdInfo += " | Profile Enabled | $ ( if ($profileEnabled ) { ' ✅ Yes' } else { ' ❌ No' }) |`n "
149+
150+ # Only show transaction and device counts if profile is enabled
151+ if ($profileEnabled ) {
152+ $mdInfo += " | M365 Transactions (7 days) | $ ( $m365TotalCount.ToString (' N0' )) |`n "
153+ $mdInfo += " | M365 Blocked Transactions | $ ( $m365BlockedCount.ToString (' N0' )) |`n "
154+ $mdInfo += " | Active Devices | $activeDeviceCount |`n "
155+ $mdInfo += " | Total Devices | $totalDeviceCount |`n "
156+ }
157+ $mdInfo += " `n "
153158
154159 # Traffic Forwarding Profile Section
155- [void ]$mdInfo.AppendLine (" `n ## Traffic Forwarding Profile`n " )
156- [void ]$mdInfo.AppendLine (" | Property | Value |" )
157- [void ]$mdInfo.AppendLine (" | :--- | :--- |" )
158- [void ]$mdInfo.AppendLine (" | Profile Name | $ ( Get-SafeMarkdown - Text $profileName ) |" )
159- [void ]$mdInfo.AppendLine (" | State | $profileState |" )
160- [void ]$mdInfo.AppendLine (" | Traffic Type | m365 |`n " )
161-
162- # Transaction Summary Section
163- [void ]$mdInfo.AppendLine (" `n ## Transaction Summary`n " )
164- [void ]$mdInfo.AppendLine (" | Traffic Type | Total Count | Blocked Count |" )
165- [void ]$mdInfo.AppendLine (" | :--- | ---: | ---: |" )
166- if ($transactionSummary ) {
167- foreach ($entry in $transactionSummary | Sort-Object trafficType) {
168- $total = [int ]$entry.totalCount
169- $blocked = [int ]$entry.blockedCount
170- [void ]$mdInfo.AppendLine (" | $ ( $entry.trafficType ) | $ ( $total.ToString (' N0' )) | $ ( $blocked.ToString (' N0' )) |" )
160+ $mdInfo += " `n ## Traffic Forwarding Profile`n`n "
161+ $mdInfo += " | Property | Value |`n "
162+ $mdInfo += " | :--- | :--- |`n "
163+ $mdInfo += " | Profile Name | $ ( Get-SafeMarkdown - Text $profileName ) |`n "
164+ $mdInfo += " | State | $profileState |`n "
165+ $mdInfo += " | Traffic Type | m365 |`n`n "
166+
167+ # Only show transaction and device data if profile is enabled
168+ if ($profileEnabled ) {
169+ # Transaction Summary Section
170+ $mdInfo += " `n ## Transaction Summary`n`n "
171+ $mdInfo += " | Traffic Type | Total Count | Blocked Count |`n "
172+ $mdInfo += " | :--- | ---: | ---: |`n "
173+ if ($transactionSummary ) {
174+ foreach ($entry in $transactionSummary | Sort-Object trafficType) {
175+ $total = [int ]$entry.totalCount
176+ $blocked = [int ]$entry.blockedCount
177+ $mdInfo += " | $ ( $entry.trafficType ) | $ ( $total.ToString (' N0' )) | $ ( $blocked.ToString (' N0' )) |`n "
178+ }
179+ } else {
180+ $mdInfo += " | - | No data available | - |`n "
171181 }
172- } else {
173- [void ]$mdInfo.AppendLine (" | - | No data available | - |" )
174- }
175- [void ]$mdInfo.AppendLine ()
176- [void ]$mdInfo.AppendLine (" *Evaluation Period: $ ( $startDateTime.ToString (' yyyy-MM-dd' )) to $ ( $endDateTime.ToString (' yyyy-MM-dd' )) *`n " )
182+ $mdInfo += " `n "
183+ $mdInfo += " *Evaluation Period: $ ( $startDateTime.ToString (' yyyy-MM-dd' )) to $ ( $endDateTime.ToString (' yyyy-MM-dd' )) *`n`n "
177184
178- # Device Usage Section
179- [void ]$mdInfo.AppendLine (" `n ## Device Usage`n " )
180- [void ]$mdInfo.AppendLine (" | Metric | Count |" )
181- [void ]$mdInfo.AppendLine (" | :--- | ---: |" )
182- [void ]$mdInfo.AppendLine (" | Total Devices | $totalDeviceCount |" )
183- [void ]$mdInfo.AppendLine (" | Active Devices | $activeDeviceCount |" )
184- [void ]$mdInfo.AppendLine (" | Inactive Devices | $inactiveDeviceCount |`n " )
185+ # Device Usage Section
186+ $mdInfo += " `n ## Device Usage`n`n "
187+ $mdInfo += " | Metric | Count |`n "
188+ $mdInfo += " | :--- | ---: |`n "
189+ $mdInfo += " | Total Devices | $totalDeviceCount |`n "
190+ $mdInfo += " | Active Devices | $activeDeviceCount |`n "
191+ $mdInfo += " | Inactive Devices | $inactiveDeviceCount |`n`n "
192+ }
185193
186194 # Warnings Section
187195 if ($warnings.Count -gt 0 ) {
188- [ void ] $mdInfo.AppendLine ( " `n ## ⚠️ Warnings`n " )
196+ $mdInfo += " `n ## ⚠️ Warnings`n`n "
189197 foreach ($warning in $warnings ) {
190- [ void ] $mdInfo.AppendLine ( " - $warning " )
198+ $mdInfo += " - $warning `n "
191199 }
192- [ void ] $mdInfo.AppendLine ()
200+ $mdInfo += " `n "
193201 }
194202
195203 # Portal Link
196- $portalLink = " https://entra.microsoft.com/#view/Microsoft_Azure_Network_Access/TrafficForwardingBlade "
197- [ void ] $mdInfo.AppendLine ( " `n [$ ( Get-SafeMarkdown - Text ' View in Entra Portal: Traffic forwarding' ) ]($portalLink )" )
204+ $portalLink = " https://entra.microsoft.com/#view/Microsoft_Azure_Network_Access/ForwardingProfile.ReactView "
205+ $mdInfo += " `n [$ ( Get-SafeMarkdown - Text ' View in Entra Portal: Traffic forwarding' ) ]($portalLink )"
198206
199207 # Replace placeholder with detailed information
200- $testResultMarkdown = $testResultMarkdown -replace ' %TestResult%' , $mdInfo.ToString ()
208+ $testResultMarkdown = $testResultMarkdown -replace ' %TestResult%' , $mdInfo
201209 # endregion Report Generation
202210
203211 $params = @ {
0 commit comments