Skip to content

Commit

Permalink
Merge pull request #3526 from NikCharlebois/Report-Fixes
Browse files Browse the repository at this point in the history
Report fixes
  • Loading branch information
NikCharlebois authored Jul 28, 2023
2 parents ef69583 + 8e96b46 commit 0651fe2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
* MISC
* M365DscReverse: Fix exporting when $Filter var exists locally
FIXES [#3515](https://github.com/microsoft/Microsoft365DSC/issues/3515)
* Fix for the delta report function to handle deep nested CIM Instances.
FIXES [#3478](https://github.com/microsoft/Microsoft365DSC/issues/3478)
* DEPENDENCIES
* Updated Microsoft.Graph.* dependencies to version 2.2.0.
* Updated dependency Microsoft.PowerApps.Administration.PowerShell to version 2.0.170.
Expand Down
32 changes: 18 additions & 14 deletions Modules/Microsoft365DSC/Modules/M365DSCReport.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,37 @@ Function New-M365DSCConfigurationToMarkdown
[Parameter()]
[Array]
$ParsedContent,

[Parameter()]
[System.String]
$OutputPath,

[Parameter()]
[System.String]
$TemplateName,

[Parameter()]
[Switch]
$SortProperties
)

$crlf = "`r`n"
if ([System.String]::IsNullOrEmpty($TemplateName))
{
$TemplateName = 'Configuration Report'
}

Write-Output 'Generating Markdown report'
$fullMD = "# " + $TemplateName + $crlf

$totalCount = $parsedContent.Count
$currentCount = 0
foreach ($resource in $parsedContent)
{
# Create a new table for each resource
$percentage = [math]::Round(($currentCount / $totalCount) * 100, 2)
Write-Progress -Activity 'Processing generated DSC Object' -Status ("{0:N2} completed - $($resource.ResourceName)" -f $percentage) -PercentComplete $percentage

$fullMD += "## " + $resource.ResourceInstanceName + $crlf
$fullMD += "|Item|Value|`r`n"
$fullMD += "|:---|:---|`r`n"
Expand All @@ -57,7 +57,7 @@ Function New-M365DSCConfigurationToMarkdown
{
$properties = $resource.Keys
}

foreach ($property in $properties)
{
if ($property -ne 'ResourceName' `
Expand Down Expand Up @@ -115,19 +115,19 @@ Function New-M365DSCConfigurationToMarkdown
$partMD += $value + $crlf
}
}

$fullMD += $partMD + $crlf
$partMD = ""

$currentCount++
}

if (-not [System.String]::IsNullOrEmpty($OutputPath))
{
Write-Output 'Saving Markdown report'
$fullMD | Out-File $OutputPath
}

Write-Output 'Completed generating Markdown report'
}

Expand Down Expand Up @@ -737,7 +737,7 @@ function Compare-M365DSCConfigurations
$foundResourceMatch = $true
foreach ($property in $instance.Keys)
{
if ($null -ne (Compare-Object -ReferenceObject ($instance."$property")`
if ($null -eq $destinationResourceInstance."$property" -or $null -ne (Compare-Object -ReferenceObject ($instance."$property")`
-DifferenceObject ($destinationResourceInstance."$property")))
{
$drift = @{
Expand Down Expand Up @@ -885,7 +885,7 @@ function Compare-M365DSCConfigurations
{
foreach ($property in $instance.Keys)
{
if ($null -ne (Compare-Object -ReferenceObject ($instance."$property")`
if ($null -eq $sourceRsourceInstance."$property" -or $null -ne (Compare-Object -ReferenceObject ($instance."$property")`
-DifferenceObject ($sourceResourceInstance."$property")))
{
# Make sure we haven't already added this drift in the delta return object to prevent duplicates.
Expand Down Expand Up @@ -1104,6 +1104,10 @@ function Get-M365DSCCIMInstanceKey
{
$primaryKey = 'Usage'
}
elseif ($CIMInstance.ContainsKey("odataType"))
{
$primaryKey = 'odataType'
}
return $primaryKey
}

Expand Down

0 comments on commit 0651fe2

Please sign in to comment.