From c18587867427118c54fc0d823a87ed2dbccaeb80 Mon Sep 17 00:00:00 2001 From: DrIOS <58635327+DrIOSX@users.noreply.github.com> Date: Sat, 8 Jun 2024 16:35:00 -0500 Subject: [PATCH 1/3] add: pipeline input for CISAuditResult object input to Sync function --- source/Public/Sync-CISExcelAndCsvData.ps1 | 86 ++++++++++++----------- 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/source/Public/Sync-CISExcelAndCsvData.ps1 b/source/Public/Sync-CISExcelAndCsvData.ps1 index 15f8be9..8842e2f 100644 --- a/source/Public/Sync-CISExcelAndCsvData.ps1 +++ b/source/Public/Sync-CISExcelAndCsvData.ps1 @@ -1,43 +1,47 @@ <# - .SYNOPSIS - Synchronizes data between an Excel file and either a CSV file or an output object from Invoke-M365SecurityAudit, and optionally updates the Excel worksheet. - .DESCRIPTION - The Sync-CISExcelAndCsvData function merges data from a specified Excel file with data from either a CSV file or an output object from Invoke-M365SecurityAudit based on a common key. It can also update the Excel worksheet with the merged data. This function is particularly useful for updating Excel records with additional data from a CSV file or audit results while preserving the original formatting and structure of the Excel worksheet. - .PARAMETER ExcelPath - The path to the Excel file that contains the original data. This parameter is mandatory. - .PARAMETER WorksheetName - The name of the worksheet within the Excel file that contains the data to be synchronized. This parameter is mandatory. - .PARAMETER CsvPath - The path to the CSV file containing data to be merged with the Excel data. This parameter is mandatory when using the CsvInput parameter set. - .PARAMETER AuditResults - An array of CISAuditResult objects from Invoke-M365SecurityAudit to be merged with the Excel data. This parameter is mandatory when using the ObjectInput parameter set. - .PARAMETER SkipUpdate - If specified, the function will return the merged data object without updating the Excel worksheet. This is useful for previewing the merged data. - .EXAMPLE - PS> Sync-CISExcelAndCsvData -ExcelPath "path\to\excel.xlsx" -WorksheetName "DataSheet" -CsvPath "path\to\data.csv" - Merges data from 'data.csv' into 'excel.xlsx' on the 'DataSheet' worksheet and updates the worksheet with the merged data. - .EXAMPLE - PS> $mergedData = Sync-CISExcelAndCsvData -ExcelPath "path\to\excel.xlsx" -WorksheetName "DataSheet" -CsvPath "path\to\data.csv" -SkipUpdate - Retrieves the merged data object for preview without updating the Excel worksheet. - .EXAMPLE - PS> $auditResults = Invoke-M365SecurityAudit -TenantAdminUrl "https://tenant-admin.url" -DomainName "example.com" - PS> Sync-CISExcelAndCsvData -ExcelPath "path\to\excel.xlsx" -WorksheetName "DataSheet" -AuditResults $auditResults - Merges data from the audit results into 'excel.xlsx' on the 'DataSheet' worksheet and updates the worksheet with the merged data. - .EXAMPLE - PS> $auditResults = Invoke-M365SecurityAudit -TenantAdminUrl "https://tenant-admin.url" -DomainName "example.com" - PS> $mergedData = Sync-CISExcelAndCsvData -ExcelPath "path\to\excel.xlsx" -WorksheetName "DataSheet" -AuditResults $auditResults -SkipUpdate - Retrieves the merged data object for preview without updating the Excel worksheet. - .INPUTS - None. You cannot pipe objects to Sync-CISExcelAndCsvData. - .OUTPUTS - Object[] - If the SkipUpdate switch is used, the function returns an array of custom objects representing the merged data. - .NOTES - - Ensure that the 'ImportExcel' module is installed and up to date. - - It is recommended to backup the Excel file before running this script to prevent accidental data loss. - - This function is part of the CIS Excel and CSV Data Management Toolkit. - .LINK - https://criticalsolutionsnetwork.github.io/M365FoundationsCISReport/#Sync-CISExcelAndCsvData +.SYNOPSIS +Synchronizes data between an Excel file and either a CSV file or an output object from Invoke-M365SecurityAudit, and optionally updates the Excel worksheet. +.DESCRIPTION +The Sync-CISExcelAndCsvData function merges data from a specified Excel file with data from either a CSV file or an output object from Invoke-M365SecurityAudit based on a common key. It can also update the Excel worksheet with the merged data. This function is particularly useful for updating Excel records with additional data from a CSV file or audit results while preserving the original formatting and structure of the Excel worksheet. +.PARAMETER ExcelPath +The path to the Excel file that contains the original data. This parameter is mandatory. +.PARAMETER WorksheetName +The name of the worksheet within the Excel file that contains the data to be synchronized. This parameter is mandatory. +.PARAMETER CsvPath +The path to the CSV file containing data to be merged with the Excel data. This parameter is mandatory when using the CsvInput parameter set. +.PARAMETER AuditResults +An array of CISAuditResult objects from Invoke-M365SecurityAudit to be merged with the Excel data. This parameter is mandatory when using the ObjectInput parameter set. It can also accept pipeline input. +.PARAMETER SkipUpdate +If specified, the function will return the merged data object without updating the Excel worksheet. This is useful for previewing the merged data. +.EXAMPLE +PS> Sync-CISExcelAndCsvData -ExcelPath "path\to\excel.xlsx" -WorksheetName "DataSheet" -CsvPath "path\to\data.csv" +Merges data from 'data.csv' into 'excel.xlsx' on the 'DataSheet' worksheet and updates the worksheet with the merged data. +.EXAMPLE +PS> $mergedData = Sync-CISExcelAndCsvData -ExcelPath "path\to\excel.xlsx" -WorksheetName "DataSheet" -CsvPath "path\to\data.csv" -SkipUpdate +Retrieves the merged data object for preview without updating the Excel worksheet. +.EXAMPLE +PS> $auditResults = Invoke-M365SecurityAudit -TenantAdminUrl "https://tenant-admin.url" -DomainName "example.com" +PS> Sync-CISExcelAndCsvData -ExcelPath "path\to\excel.xlsx" -WorksheetName "DataSheet" -AuditResults $auditResults +Merges data from the audit results into 'excel.xlsx' on the 'DataSheet' worksheet and updates the worksheet with the merged data. +.EXAMPLE +PS> $auditResults = Invoke-M365SecurityAudit -TenantAdminUrl "https://tenant-admin.url" -DomainName "example.com" +PS> $mergedData = Sync-CISExcelAndCsvData -ExcelPath "path\to\excel.xlsx" -WorksheetName "DataSheet" -AuditResults $auditResults -SkipUpdate +Retrieves the merged data object for preview without updating the Excel worksheet. +.EXAMPLE +PS> Invoke-M365SecurityAudit -TenantAdminUrl "https://tenant-admin.url" -DomainName "example.com" | Sync-CISExcelAndCsvData -ExcelPath "path\to\excel.xlsx" -WorksheetName "DataSheet" +Pipes the audit results into Sync-CISExcelAndCsvData to merge data into 'excel.xlsx' on the 'DataSheet' worksheet and updates the worksheet with the merged data. +.INPUTS +System.String, CISAuditResult[] +You can pipe CISAuditResult objects to Sync-CISExcelAndCsvData. +.OUTPUTS +Object[] +If the SkipUpdate switch is used, the function returns an array of custom objects representing the merged data. +.NOTES +- Ensure that the 'ImportExcel' module is installed and up to date. +- It is recommended to backup the Excel file before running this script to prevent accidental data loss. +- This function is part of the CIS Excel and CSV Data Management Toolkit. +.LINK +https://criticalsolutionsnetwork.github.io/M365FoundationsCISReport/#Sync-CISExcelAndCsvData #> function Sync-CISExcelAndCsvData { [CmdletBinding(DefaultParameterSetName = 'CsvInput')] @@ -53,7 +57,7 @@ function Sync-CISExcelAndCsvData { [ValidateScript({ Test-Path $_ })] [string]$CsvPath, - [Parameter(Mandatory = $true, ParameterSetName = 'ObjectInput')] + [Parameter(Mandatory = $true, ParameterSetName = 'ObjectInput', ValueFromPipeline = $true)] [CISAuditResult[]]$AuditResults, [Parameter(Mandatory = $false)] @@ -83,5 +87,3 @@ function Sync-CISExcelAndCsvData { } } } - - From 0d97b95c6cff816844d4e9de62c2e6865fc4488e Mon Sep 17 00:00:00 2001 From: DrIOS <58635327+DrIOSX@users.noreply.github.com> Date: Sat, 8 Jun 2024 16:38:24 -0500 Subject: [PATCH 2/3] docs: Update changelog --- CHANGELOG.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18e8a5e..9dca7b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ The format is based on and uses the types of changes according to [Keep a Change ### Added +- Added pipeline support to `Sync-CISExcelAndCsvData` function for `[CISAuditResult[]]` input. + +## [0.1.5] - 2024-06-08 + +### Added + - Updated test definitions for CIS Microsoft 365 Foundations Benchmark for better error handling and object output when errors occur. - Added a parameter to the `Initialize-CISAuditResult` function to allow for a static failed object to be created when an error occurs. - Refactored `Invoke-M365SecurityAudit` to include a new private function `Invoke-TestFunction` for executing test functions and handling errors. @@ -34,8 +40,6 @@ The format is based on and uses the types of changes according to [Keep a Change - Added step 1 and step 2 in `Test-BlockMailForwarding` details to ensure comprehensive compliance checks. - Fixed the issue with the output in `Test-RestrictCustomScripts` to ensure no extra spaces between table headers and data. - - ## [0.1.4] - 2024-05-30 ### Added From 055ab422612dfc2482500de955398425988f99a0 Mon Sep 17 00:00:00 2001 From: DrIOS <58635327+DrIOSX@users.noreply.github.com> Date: Sat, 8 Jun 2024 16:40:58 -0500 Subject: [PATCH 3/3] docs: Update docs/README --- README.md | Bin 23626 -> 24558 bytes docs/index.html | Bin 65852 -> 66884 bytes helpers/Build-Help.ps1 | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c33fe48f53be4bd1151bfb8226d393281dfd2fdd..956c8f35beb2e356587e47b82e0d9dd3d075a764 100644 GIT binary patch delta 297 zcmX@LgYn&d#tm1z>^&Ju7!(+i84?-tfOH~54nr|RKA4pZ6isC)0LvFJWCB^KK-o;7 zx>TS%h%R6#oy_kkDPO`+#83(rjbYGWaAK%r2m_l05{qHboNVYRznRZ_1*3E@P^uVc zU@Ai{gC0XLkW~aWD4juP@_a*0@kpT6rAW?!S__nupS;aeX!9qZJ-m}wScov1PA=qE zpFF`TWpYGl7_$OH&E)?Pp_2;&*(S3D`iS!~a4{r+A&3&w&OD0D}e*ge#j!RMi delta 47 zcmV+~0MP&LzX8g)0kG6clNL!jlbi_%lbTu#vwlmI0h0y{LbIezwhfcqO$d_?6Qq;= FUhwGe6j=ZO diff --git a/docs/index.html b/docs/index.html index 81728b49e8dc5d21d9d241ed8190634662fd65d2..93cd28e8b7fca8f70efea22a9016c3775bbf6d39 100644 GIT binary patch delta 289 zcmdnf#B!vIWx_pPGX^ULV+KngX~mP2?UIv|y7V?T z9q|#F{9pplBpWS8)5#Ynt(^SkQW&!WL(OEt3(F^~%r;^MI%zWF9Mj1iNA#o>fF^>R zoeQ*~h#?*9loX&NN*EF+uRV8uvVe%d7nmmV-PPNiaOaK+0BU(t AnE(I) delta 71 zcmX@o#j>Y~Wx_pPQwA#rQy{crFk~>^__}`2=2<)Y7&iy(_hX$b(c!dN@2H!|WC0O@ Y$qfrb!1RHKN}CPlo@3f<^?*wi0GsI=wEzGB diff --git a/helpers/Build-Help.ps1 b/helpers/Build-Help.ps1 index fd7469b..933f032 100644 --- a/helpers/Build-Help.ps1 +++ b/helpers/Build-Help.ps1 @@ -4,7 +4,7 @@ Import-Module .\output\module\M365FoundationsCISReport\*\*.psd1 <# - $ver = "v0.1.5" + $ver = "v0.1.6" git checkout main git pull origin main git tag -a $ver -m "Release version $ver refactor Update"