diff --git a/Functions/Export-JamfHTMLReport.ps1 b/Functions/Export-JamfHTMLReport.ps1 index a5fb65a..db58103 100644 --- a/Functions/Export-JamfHTMLReport.ps1 +++ b/Functions/Export-JamfHTMLReport.ps1 @@ -1,11 +1,52 @@ -function Export-JamfHTMLReport { - param ( - [Parameter(Mandatory = $true)] - [string]$FilePath - ) - - # HTML template with placeholders for JAMF-specific content - $htmlTemplate = @" +function Export-JamfHTMLReport { + param ( + [Parameter(Mandatory = $true)] + [string]$FilePath + ) + + function Get-BadgeClass { + param ( + [string]$AssignmentType + ) + + switch ($AssignmentType) { + 'All Computers' { 'badge-all-computers' } + 'Computer Group' { 'badge-computer-group' } + 'Computer' { 'badge-computer' } + 'Mobile Device Group'{ 'badge-mobile-device-group' } + 'User Group' { 'badge-user-group' } + 'User' { 'badge-user' } + 'Building' { 'badge-building' } + 'Exclude' { 'badge-exclude' } + default { 'badge-none' } + } + } + + function Get-DisplayData { + param ( + [Parameter(Mandatory = $true)] + [object]$Resource + ) + + $resourceObject = if ($Resource -is [hashtable]) { [pscustomobject]$Resource } else { $Resource } + + $assignmentType = if ([string]::IsNullOrWhiteSpace($resourceObject.AssignmentType)) { 'None' } else { $resourceObject.AssignmentType } + $assignedTo = if ([string]::IsNullOrWhiteSpace($resourceObject.AssignedTo)) { 'Not Assigned' } else { $resourceObject.AssignedTo } + $exclusions = if ([string]::IsNullOrWhiteSpace($resourceObject.Exclusions)) { 'None' } else { $resourceObject.Exclusions } + + return [pscustomobject]@{ + Name = if ($resourceObject.Name) { Escape-Html $resourceObject.Name } else { '[Unknown]' } + Type = if ($resourceObject.Type) { Escape-Html $resourceObject.Type } else { '[Unknown]' } + AssignmentType = Escape-Html $assignmentType + AssignmentTypeRaw = $assignmentType + AssignedTo = Escape-Html $assignedTo + Exclusions = Escape-Html $exclusions + Enabled = if ($null -ne $resourceObject.Enabled) { [bool]$resourceObject.Enabled } else { $null } + } + } + + # HTML template with placeholders for JAMF-specific content + $htmlTemplate = @" @@ -351,25 +392,27 @@ function Export-JamfHTMLReport {