src/Private/Report/PPT/Build-MCSHighImpactSlide.ps1
|
function Build-MCSHighImpactSlide { Param($Presentation,$HighRecommendation,$Debug) if ($Debug.IsPresent) { $DebugPreference = "Continue" } else { $DebugPreference = "SilentlyContinue" } $FirstSlide = 14 $TableID = 15 $CurrentSlide = $Presentation.Slides | Where-Object { $_.SlideIndex -eq $FirstSlide } $row = 2 $Counter = 1 $RecomNumber = 1 foreach ($High in $HighRecommendation) { $RecomName = $High.Recommendation $Implication = $High.Implication Write-Debug ((get-date -Format 'yyyy-MM-dd HH:mm:ss') + ' - Editing High Impact Slide - Adding Recommendation: ' + $RecomName) if ($Counter -lt 6) { ($CurrentSlide.Shapes | Where-Object { $_.Id -eq $TableID }).Table.Rows($row).Cells(1).Shape.TextFrame.TextRange.Text = [string]$RecomNumber ($CurrentSlide.Shapes | Where-Object { $_.Id -eq $TableID }).Table.Rows($row).Cells(2).Shape.TextFrame.TextRange.Text = [string]$RecomName ($CurrentSlide.Shapes | Where-Object { $_.Id -eq $TableID }).Table.Rows($row).Cells(3).Shape.TextFrame.TextRange.Text = [string]$Implication $row ++ $Counter ++ $RecomNumber ++ start-sleep -Milliseconds 100 } else { Write-Debug ((get-date -Format 'yyyy-MM-dd HH:mm:ss') + ' - Editing High Impact Slide - Adding new Slide..') $Counter = 1 $Presentation.slides[$FirstSlide].Duplicate() | Out-Null $FirstSlide ++ $NextSlide = $Presentation.Slides | Where-Object { $_.SlideIndex -eq $FirstSlide } Start-Sleep -Seconds 1 Write-Debug ((get-date -Format 'yyyy-MM-dd HH:mm:ss') + ' - Editing High Impact Slide - Cleaning table of new slide..') $rowTemp = 2 while ($rowTemp -lt 7) { $cell = 1 while ($cell -lt 4) { ($NextSlide.Shapes | Where-Object { $_.Id -eq $TableID }).Table.Rows($rowTemp).Cells($cell).Shape.TextFrame.TextRange.Text = '' $cell ++ } $rowTemp ++ } $CurrentSlide = $NextSlide $row = 2 ($CurrentSlide.Shapes | Where-Object { $_.Id -eq $TableID }).Table.Rows($row).Cells(1).Shape.TextFrame.TextRange.Text = [string]$RecomNumber ($CurrentSlide.Shapes | Where-Object { $_.Id -eq $TableID }).Table.Rows($row).Cells(2).Shape.TextFrame.TextRange.Text = [string]$RecomName ($CurrentSlide.Shapes | Where-Object { $_.Id -eq $TableID }).Table.Rows($row).Cells(3).Shape.TextFrame.TextRange.Text = [string]$Implication $row ++ $Counter ++ $RecomNumber ++ start-sleep -Milliseconds 100 } } } |