tmaestrini / easyGovernance

governance and validation for configuration baselines in M365 – made as easy as possible
MIT License
11 stars 4 forks source link

Report generation #18

Open tmaestrini opened 3 months ago

tmaestrini commented 3 months ago

To get a proper overview over the services within the tenant, a function to generate a validation report (Markdown) should be implemented.

tmaestrini commented 3 months ago

First attempt is done – ready for a review: check out the branch '18-report-generation'.

A report can be generated very easily by taking the validation output and feed it into the New-Report cmdlet. First of all, a markdown file (yyyymmmddHHmm-Report.md) will be written in ./outputs directory:

# Validate a given tenant from settings file
Import-Module .\src\Validation.psm1 -Force
$a = Start-Validation -TemplateName "tmaestrini.yml" -ReturnAsObject 

New-Report -ValidationResults $a -AsHTML

If you would like to generate an according HTML representation, just add the parameter -As HTML:

# Validate a given tenant from settings file
Import-Module .\src\Validation.psm1 -Force
$a = Start-Validation -TemplateName "tmaestrini.yml" -ReturnAsObject 

New-Report -ValidationResults $a -AsHTML

You're good to go! πŸ˜‰

image

tmaestrini commented 3 months ago

@sympmarc What do you think about this?

sympmarc commented 3 months ago

@tmaestrini - That's beautiful!

I haven't tried to debug it yet, but I'm getting this error:

Set-LoggingDefaultLevel: The term 'Set-LoggingDefaultLevel' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or
if a path was included, verify that the path is correct and try again.

on the line

$a = Start-Validation -TemplateName "sympraxis.yml" -ReturnAsObject 
tmaestrini commented 3 months ago

Hey @sympmarc, glad you've tested it.

  1. Make sure you're on branch 18-...
  2. Install this module: Install-Module -Name Logging -RequiredVersion 4.8.5 -Scope CurrentUser

I've introduced the Logging module instead of simply printing output to the console.

Does this work?

sympmarc commented 3 months ago

Ignore that error. Solved!

It looks like I'm getting HTML in the MD file, but it looks great.

sympmarc commented 3 months ago

New-Report -ValidationResults $a gives me an MD file containing HTML

New-Report -ValidationResults $a -AsHTML gives me this error. Think I'm just missing a file.

[2024-04-05 14:41:12-04] [INFO ] Markdown report created: C:\code\Governance\easyGovernace-18-report-generation\easyGovernance\src\Public\Validation......\output/202404051441-Report.md Convert-MarkdownToHTML: C:\code\Governance\easyGovernace-18-report-generation\easyGovernance\src\Public\Validation\New-Report.ps1:68:24 Line | 68 | $htmlOutput = Convert-MarkdownToHTML $reportFilePath -SiteDi … | ~~~~~~ | The term 'Convert-MarkdownToHTML' is not recognized as a name of a cmdlet, function, script file, or executable
| program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Copy-Item: C:\code\Governance\easyGovernace-18-report-generation\easyGovernance\src\Public\Validation\New-Report.ps1:69:10
Line | 69 | Copy-Item -Path (Join-Path $PSScriptRoot -ChildPath '../../. … | ~~~~~~~~~~~~ | Could not find a part of the path | 'C:\code\Governance\easyGovernace-18-report-generation\easyGovernance\output\styles\md-styles.css'.

PS C:\code\Governance\easyGovernace-18-report-generation\easyGovernance> [2024-04-05 14:41:12-04] [INFO ] HTML report created:

sympmarc commented 3 months ago

Needed this module: Install-Module -Name MarkdownToHTML (as you know!)

sympmarc commented 3 months ago

FYI - the settings_template.yml file doesn't match the baselines available in \easyGovernance\baselines

tmaestrini commented 3 months ago

FYI - the settings_template.yml file doesn't match the baselines available in \easyGovernance\baselines

Thanks for this. Didn't have it on the radar. Will fix it asap. πŸ’ͺπŸ’ͺπŸ’ͺ

tmaestrini commented 3 months ago

Needed this module:

Install-Module -Name MarkdownToHTML

(as you know!)

I should add this Module as dependencies. Sorry for the poor communication on my part.

sympmarc commented 3 months ago

No worries. All part of testing.

Looks like you're also missing a validation ps1 for M365.IAM-1-2.1.yml.

tmaestrini commented 3 months ago

Does the mix of MD and HTML cause distraction? If it does, we could tidy up an generate "pure" MD and write an adapter for the HTML content.

sympmarc commented 3 months ago

For now, it certainly works. It's nice-looking output. Technically, it's not markdown.

tmaestrini commented 3 months ago

Yes, you're right. I think we should tidy it up. It's still work in progress.

But over all - do you like the "content" and the style of the presentation? I mean over all: are we facing the right direction?

sympmarc commented 3 months ago

Absolutely. The output looks good and is suitable to put into a PowerPoint or to share with management.

tmaestrini commented 2 months ago

βœ”οΈŽ Report generation was merged to develop and main branch

Adam-it commented 2 months ago

Hey @tmaestrini do you consider supporting other report types? I explain which and why

tmaestrini commented 2 months ago

That's a great idea, @Adam-it . We will work it out and let you know. Thanks for your contribution, you're a πŸš€