Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report fixes #3526

Merged
merged 2 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,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