docs: Update Comment Help
This commit is contained in:
@@ -21,30 +21,30 @@
|
|||||||
Switch to export the results to an Excel file. When specified, results are exported in Excel format.
|
Switch to export the results to an Excel file. When specified, results are exported in Excel format.
|
||||||
.INPUTS
|
.INPUTS
|
||||||
[CISAuditResult[]] - An array of CISAuditResult objects.
|
[CISAuditResult[]] - An array of CISAuditResult objects.
|
||||||
[string] - A path to a CSV file.
|
[string] - A path to a CSV file.
|
||||||
.OUTPUTS
|
.OUTPUTS
|
||||||
[PSCustomObject] - A custom object containing the path to the zip file and its hash.
|
[PSCustomObject] - A custom object containing the path to the zip file and its hash.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
Export-M365SecurityAuditTable -AuditResults $object -OutputTestNumber 6.1.2
|
Export-M365SecurityAuditTable -AuditResults $object -OutputTestNumber 6.1.2
|
||||||
# Outputs the result of test number 6.1.2 from the provided audit results as an object.
|
# Outputs the result of test number 6.1.2 from the provided audit results as an object.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
Export-M365SecurityAuditTable -ExportAllTests -AuditResults $object -ExportPath "C:\temp"
|
Export-M365SecurityAuditTable -ExportAllTests -AuditResults $object -ExportPath "C:\temp"
|
||||||
# Exports all audit results to the specified path in CSV format.
|
# Exports all audit results to the specified path in CSV format.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
Export-M365SecurityAuditTable -CsvPath "C:\temp\auditresultstoday1.csv" -OutputTestNumber 6.1.2
|
Export-M365SecurityAuditTable -CsvPath "C:\temp\auditresultstoday1.csv" -OutputTestNumber 6.1.2
|
||||||
# Outputs the result of test number 6.1.2 from the CSV file as an object.
|
# Outputs the result of test number 6.1.2 from the CSV file as an object.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
Export-M365SecurityAuditTable -ExportAllTests -CsvPath "C:\temp\auditresultstoday1.csv" -ExportPath "C:\temp"
|
Export-M365SecurityAuditTable -ExportAllTests -CsvPath "C:\temp\auditresultstoday1.csv" -ExportPath "C:\temp"
|
||||||
# Exports all audit results from the CSV file to the specified path in CSV format.
|
# Exports all audit results from the CSV file to the specified path in CSV format.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
Export-M365SecurityAuditTable -ExportAllTests -AuditResults $object -ExportPath "C:\temp" -ExportOriginalTests
|
Export-M365SecurityAuditTable -ExportAllTests -AuditResults $object -ExportPath "C:\temp" -ExportOriginalTests
|
||||||
# Exports all audit results along with the original test results to the specified path in CSV format.
|
# Exports all audit results along with the original test results to the specified path in CSV format.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
Export-M365SecurityAuditTable -ExportAllTests -CsvPath "C:\temp\auditresultstoday1.csv" -ExportPath "C:\temp" -ExportOriginalTests
|
Export-M365SecurityAuditTable -ExportAllTests -CsvPath "C:\temp\auditresultstoday1.csv" -ExportPath "C:\temp" -ExportOriginalTests
|
||||||
# Exports all audit results from the CSV file along with the original test results to the specified path in CSV format.
|
# Exports all audit results from the CSV file along with the original test results to the specified path in CSV format.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
Export-M365SecurityAuditTable -ExportAllTests -AuditResults $object -ExportPath "C:\temp" -ExportToExcel
|
Export-M365SecurityAuditTable -ExportAllTests -AuditResults $object -ExportPath "C:\temp" -ExportToExcel
|
||||||
# Exports all audit results to the specified path in Excel format.
|
# Exports all audit results to the specified path in Excel format.
|
||||||
.LINK
|
.LINK
|
||||||
https://criticalsolutionsnetwork.github.io/M365FoundationsCISReport/#Export-M365SecurityAuditTable
|
https://criticalsolutionsnetwork.github.io/M365FoundationsCISReport/#Export-M365SecurityAuditTable
|
||||||
#>
|
#>
|
||||||
|
@@ -8,19 +8,19 @@
|
|||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> Get-AdminRoleUserLicense
|
PS> Get-AdminRoleUserLicense
|
||||||
|
|
||||||
This example retrieves all administrative role users along with their licenses by connecting to Microsoft Graph using the default scopes.
|
This example retrieves all administrative role users along with their licenses by connecting to Microsoft Graph using the default scopes.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> Get-AdminRoleUserLicense -SkipGraphConnection
|
PS> Get-AdminRoleUserLicense -SkipGraphConnection
|
||||||
|
|
||||||
This example retrieves all administrative role users along with their licenses without attempting to connect to Microsoft Graph, assuming that the connection is already established.
|
This example retrieves all administrative role users along with their licenses without attempting to connect to Microsoft Graph, assuming that the connection is already established.
|
||||||
.INPUTS
|
.INPUTS
|
||||||
None. You cannot pipe objects to Get-AdminRoleUserLicense.
|
None. You cannot pipe objects to Get-AdminRoleUserLicense.
|
||||||
.OUTPUTS
|
.OUTPUTS
|
||||||
PSCustomObject
|
PSCustomObject
|
||||||
Returns a custom object for each user with administrative roles that includes the following properties: RoleName, UserName, UserPrincipalName, UserId, HybridUser, and Licenses.
|
Returns a custom object for each user with administrative roles that includes the following properties: RoleName, UserName, UserPrincipalName, UserId, HybridUser, and Licenses.
|
||||||
.NOTES
|
.NOTES
|
||||||
Creation Date: 2024-04-15
|
Creation Date: 2024-04-15
|
||||||
Purpose/Change: Initial function development to support Microsoft 365 administrative role auditing.
|
Purpose/Change: Initial function development to support Microsoft 365 administrative role auditing.
|
||||||
.LINK
|
.LINK
|
||||||
https://criticalsolutionsnetwork.github.io/M365FoundationsCISReport/#Get-AdminRoleUserLicense
|
https://criticalsolutionsnetwork.github.io/M365FoundationsCISReport/#Get-AdminRoleUserLicense
|
||||||
#>
|
#>
|
||||||
|
@@ -7,20 +7,20 @@
|
|||||||
The User Principal Name (UPN) of a specific user to retrieve MFA status for. If not provided, the function retrieves MFA status for all users.
|
The User Principal Name (UPN) of a specific user to retrieve MFA status for. If not provided, the function retrieves MFA status for all users.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
Get-MFAStatus
|
Get-MFAStatus
|
||||||
Retrieves the MFA status for all Azure Active Directory users.
|
Retrieves the MFA status for all Azure Active Directory users.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
Get-MFAStatus -UserId "example@domain.com"
|
Get-MFAStatus -UserId "example@domain.com"
|
||||||
Retrieves the MFA status for the specified user with the UPN "example@domain.com".
|
Retrieves the MFA status for the specified user with the UPN "example@domain.com".
|
||||||
.OUTPUTS
|
.OUTPUTS
|
||||||
System.Object
|
System.Object
|
||||||
Returns a sorted list of custom objects containing the following properties:
|
Returns a sorted list of custom objects containing the following properties:
|
||||||
- UserPrincipalName
|
- UserPrincipalName
|
||||||
- DisplayName
|
- DisplayName
|
||||||
- MFAState
|
- MFAState
|
||||||
- MFADefaultMethod
|
- MFADefaultMethod
|
||||||
- MFAPhoneNumber
|
- MFAPhoneNumber
|
||||||
- PrimarySMTP
|
- PrimarySMTP
|
||||||
- Aliases
|
- Aliases
|
||||||
.NOTES
|
.NOTES
|
||||||
The function requires the MSOL module to be installed and connected to your tenant.
|
The function requires the MSOL module to be installed and connected to your tenant.
|
||||||
Ensure that you have the necessary permissions to read user and MFA status information.
|
Ensure that you have the necessary permissions to read user and MFA status information.
|
||||||
|
@@ -16,11 +16,11 @@
|
|||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
Grant-M365SecurityAuditConsent -UserPrincipalNameForConsent user@example.com
|
Grant-M365SecurityAuditConsent -UserPrincipalNameForConsent user@example.com
|
||||||
|
|
||||||
Grants Microsoft Graph permissions to user@example.com for the client application with the specified Application ID.
|
Grants Microsoft Graph permissions to user@example.com for the client application with the specified Application ID.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
Grant-M365SecurityAuditConsent -UserPrincipalNameForConsent user@example.com -SkipGraphConnection
|
Grant-M365SecurityAuditConsent -UserPrincipalNameForConsent user@example.com -SkipGraphConnection
|
||||||
|
|
||||||
Grants Microsoft Graph permissions to user@example.com, skipping the connection to Microsoft Graph.
|
Grants Microsoft Graph permissions to user@example.com, skipping the connection to Microsoft Graph.
|
||||||
.NOTES
|
.NOTES
|
||||||
This function requires the Microsoft.Graph module version 2.4.0 or higher.
|
This function requires the Microsoft.Graph module version 2.4.0 or higher.
|
||||||
.LINK
|
.LINK
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
The URL of the tenant admin. If not specified, none of the SharePoint Online tests will run.
|
The URL of the tenant admin. If not specified, none of the SharePoint Online tests will run.
|
||||||
.PARAMETER DomainName
|
.PARAMETER DomainName
|
||||||
The domain name of the Microsoft 365 environment to test. It is optional and will trigger various tests to run only for the specified domain.
|
The domain name of the Microsoft 365 environment to test. It is optional and will trigger various tests to run only for the specified domain.
|
||||||
Tests Affected: 2.1.9/Test-EnableDKIM, 1.3.1/Test-PasswordNeverExpirePolicy, 2.1.4/Test-SafeAttachmentsPolicy
|
Tests Affected: 2.1.9/Test-EnableDKIM, 1.3.1/Test-PasswordNeverExpirePolicy, 2.1.4/Test-SafeAttachmentsPolicy
|
||||||
.PARAMETER ELevel
|
.PARAMETER ELevel
|
||||||
Specifies the E-Level (E3 or E5) for the audit. This parameter is optional and can be combined with the ProfileLevel parameter.
|
Specifies the E-Level (E3 or E5) for the audit. This parameter is optional and can be combined with the ProfileLevel parameter.
|
||||||
.PARAMETER ProfileLevel
|
.PARAMETER ProfileLevel
|
||||||
@@ -25,10 +25,10 @@
|
|||||||
Specifies specific recommendations to exclude from the audit. Accepts an array of recommendation numbers.
|
Specifies specific recommendations to exclude from the audit. Accepts an array of recommendation numbers.
|
||||||
.PARAMETER ApprovedCloudStorageProviders
|
.PARAMETER ApprovedCloudStorageProviders
|
||||||
Specifies the approved cloud storage providers for the audit. Accepts an array of cloud storage provider names for test 8.1.1/Test-TeamsExternalFileSharing.
|
Specifies the approved cloud storage providers for the audit. Accepts an array of cloud storage provider names for test 8.1.1/Test-TeamsExternalFileSharing.
|
||||||
Acceptable values: 'GoogleDrive', 'ShareFile', 'Box', 'DropBox', 'Egnyte'
|
Acceptable values: 'GoogleDrive', 'ShareFile', 'Box', 'DropBox', 'Egnyte'
|
||||||
.PARAMETER ApprovedFederatedDomains
|
.PARAMETER ApprovedFederatedDomains
|
||||||
Specifies the approved federated domains for the audit test 8.2.1/Test-TeamsExternalAccess. Accepts an array of allowed domain names.
|
Specifies the approved federated domains for the audit test 8.2.1/Test-TeamsExternalAccess. Accepts an array of allowed domain names.
|
||||||
Additional Tests may include this parameter in the future.
|
Additional Tests may include this parameter in the future.
|
||||||
.PARAMETER DoNotConnect
|
.PARAMETER DoNotConnect
|
||||||
If specified, the cmdlet will not establish a connection to Microsoft 365 services.
|
If specified, the cmdlet will not establish a connection to Microsoft 365 services.
|
||||||
.PARAMETER DoNotDisconnect
|
.PARAMETER DoNotDisconnect
|
||||||
@@ -40,90 +40,91 @@
|
|||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> Invoke-M365SecurityAudit
|
PS> Invoke-M365SecurityAudit
|
||||||
|
|
||||||
Performs a security audit using default parameters.
|
Performs a security audit using default parameters.
|
||||||
Output:
|
Output:
|
||||||
|
|
||||||
Status : Fail
|
Status : Fail
|
||||||
ELevel : E3
|
ELevel : E3
|
||||||
ProfileLevel: L1
|
ProfileLevel: L1
|
||||||
Connection : Microsoft Graph
|
Connection : Microsoft Graph
|
||||||
Rec : 1.1.1
|
Rec : 1.1.1
|
||||||
Result : False
|
Result : False
|
||||||
Details : Non-compliant accounts:
|
Details : Non-compliant accounts:
|
||||||
Username | Roles | HybridStatus | Missing Licence
|
Username | Roles | HybridStatus | Missing Licence
|
||||||
user1@domain.com| Global Administrator | Cloud-Only | AAD_PREMIUM
|
user1@domain.com| Global Administrator | Cloud-Only | AAD_PREMIUM
|
||||||
user2@domain.com| Global Administrator | Hybrid | AAD_PREMIUM, AAD_PREMIUM_P2
|
user2@domain.com| Global Administrator | Hybrid | AAD_PREMIUM, AAD_PREMIUM_P2
|
||||||
FailureReason: Non-Compliant Accounts: 2
|
FailureReason: Non-Compliant Accounts: 2
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> Invoke-M365SecurityAudit -TenantAdminUrl "https://contoso-admin.sharepoint.com" -DomainName "contoso.com" -ELevel "E5" -ProfileLevel "L1"
|
PS> Invoke-M365SecurityAudit -TenantAdminUrl "https://contoso-admin.sharepoint.com" -DomainName "contoso.com" -ELevel "E5" -ProfileLevel "L1"
|
||||||
|
|
||||||
Performs a security audit for the E5 level and L1 profile in the specified Microsoft 365 environment.
|
Performs a security audit for the E5 level and L1 profile in the specified Microsoft 365 environment.
|
||||||
Output:
|
Output:
|
||||||
|
|
||||||
Status : Fail
|
Status : Fail
|
||||||
ELevel : E5
|
ELevel : E5
|
||||||
ProfileLevel: L1
|
ProfileLevel: L1
|
||||||
Connection : Microsoft Graph
|
Connection : Microsoft Graph
|
||||||
Rec : 1.1.1
|
Rec : 1.1.1
|
||||||
Result : False
|
Result : False
|
||||||
Details : Non-compliant accounts:
|
Details : Non-compliant accounts:
|
||||||
Username | Roles | HybridStatus | Missing Licence
|
Username | Roles | HybridStatus | Missing Licence
|
||||||
user1@domain.com| Global Administrator | Cloud-Only | AAD_PREMIUM
|
user1@domain.com| Global Administrator | Cloud-Only | AAD_PREMIUM
|
||||||
user2@domain.com| Global Administrator | Hybrid | AAD_PREMIUM, AAD_PREMIUM_P2
|
user2@domain.com| Global Administrator | Hybrid | AAD_PREMIUM, AAD_PREMIUM_P2
|
||||||
FailureReason: Non-Compliant Accounts: 2
|
FailureReason: Non-Compliant Accounts: 2
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> Invoke-M365SecurityAudit -TenantAdminUrl "https://contoso-admin.sharepoint.com" -DomainName "contoso.com" -IncludeIG1
|
PS> Invoke-M365SecurityAudit -TenantAdminUrl "https://contoso-admin.sharepoint.com" -DomainName "contoso.com" -IncludeIG1
|
||||||
|
|
||||||
Performs an audit including all tests where IG1 is true.
|
Performs an audit including all tests where IG1 is true.
|
||||||
Output:
|
Output:
|
||||||
|
|
||||||
Status : Fail
|
Status : Fail
|
||||||
ELevel : E3
|
ELevel : E3
|
||||||
ProfileLevel: L1
|
ProfileLevel: L1
|
||||||
Connection : Microsoft Graph
|
Connection : Microsoft Graph
|
||||||
Rec : 1.1.1
|
Rec : 1.1.1
|
||||||
Result : False
|
Result : False
|
||||||
Details : Non-compliant accounts:
|
Details : Non-compliant accounts:
|
||||||
Username | Roles | HybridStatus | Missing Licence
|
Username | Roles | HybridStatus | Missing Licence
|
||||||
user1@domain.com| Global Administrator | Cloud-Only | AAD_PREMIUM
|
user1@domain.com| Global Administrator | Cloud-Only | AAD_PREMIUM
|
||||||
user2@domain.com| Global Administrator | Hybrid | AAD_PREMIUM, AAD_PREMIUM_P2
|
user2@domain.com| Global Administrator | Hybrid | AAD_PREMIUM, AAD_PREMIUM_P2
|
||||||
FailureReason: Non-Compliant Accounts: 2
|
FailureReason: Non-Compliant Accounts: 2
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> Invoke-M365SecurityAudit -TenantAdminUrl "https://contoso-admin.sharepoint.com" -DomainName "contoso.com" -SkipRecommendation '1.1.3', '2.1.1'
|
PS> Invoke-M365SecurityAudit -TenantAdminUrl "https://contoso-admin.sharepoint.com" -DomainName "contoso.com" -SkipRecommendation '1.1.3', '2.1.1'
|
||||||
Performs an audit while excluding specific recommendations 1.1.3 and 2.1.1.
|
|
||||||
Output:
|
|
||||||
|
|
||||||
Status : Fail
|
Performs an audit while excluding specific recommendations 1.1.3 and 2.1.1.
|
||||||
ELevel : E3
|
Output:
|
||||||
ProfileLevel: L1
|
|
||||||
Connection : Microsoft Graph
|
Status : Fail
|
||||||
Rec : 1.1.1
|
ELevel : E3
|
||||||
Result : False
|
ProfileLevel: L1
|
||||||
Details : Non-compliant accounts:
|
Connection : Microsoft Graph
|
||||||
Username | Roles | HybridStatus | Missing Licence
|
Rec : 1.1.1
|
||||||
user1@domain.com| Global Administrator | Cloud-Only | AAD_PREMIUM
|
Result : False
|
||||||
user2@domain.com| Global Administrator | Hybrid | AAD_PREMIUM, AAD_PREMIUM_P2
|
Details : Non-compliant accounts:
|
||||||
FailureReason: Non-Compliant Accounts: 2
|
Username | Roles | HybridStatus | Missing Licence
|
||||||
|
user1@domain.com| Global Administrator | Cloud-Only | AAD_PREMIUM
|
||||||
|
user2@domain.com| Global Administrator | Hybrid | AAD_PREMIUM, AAD_PREMIUM_P2
|
||||||
|
FailureReason: Non-Compliant Accounts: 2
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> $auditResults = Invoke-M365SecurityAudit -TenantAdminUrl "https://contoso-admin.sharepoint.com" -DomainName "contoso.com"
|
PS> $auditResults = Invoke-M365SecurityAudit -TenantAdminUrl "https://contoso-admin.sharepoint.com" -DomainName "contoso.com"
|
||||||
PS> $auditResults | Export-Csv -Path "auditResults.csv" -NoTypeInformation
|
PS> $auditResults | Export-Csv -Path "auditResults.csv" -NoTypeInformation
|
||||||
|
|
||||||
Captures the audit results into a variable and exports them to a CSV file.
|
Captures the audit results into a variable and exports them to a CSV file.
|
||||||
Output:
|
Output:
|
||||||
CISAuditResult[]
|
CISAuditResult[]
|
||||||
auditResults.csv
|
auditResults.csv
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> Invoke-M365SecurityAudit -WhatIf
|
PS> Invoke-M365SecurityAudit -WhatIf
|
||||||
|
|
||||||
Displays what would happen if the cmdlet is run without actually performing the audit.
|
Displays what would happen if the cmdlet is run without actually performing the audit.
|
||||||
Output:
|
Output:
|
||||||
|
|
||||||
What if: Performing the operation "Invoke-M365SecurityAudit" on target "Microsoft 365 environment".
|
What if: Performing the operation "Invoke-M365SecurityAudit" on target "Microsoft 365 environment".
|
||||||
.INPUTS
|
.INPUTS
|
||||||
None. You cannot pipe objects to Invoke-M365SecurityAudit.
|
None. You cannot pipe objects to Invoke-M365SecurityAudit.
|
||||||
.OUTPUTS
|
.OUTPUTS
|
||||||
CISAuditResult[]
|
CISAuditResult[]
|
||||||
The cmdlet returns an array of CISAuditResult objects representing the results of the security audit.
|
The cmdlet returns an array of CISAuditResult objects representing the results of the security audit.
|
||||||
.NOTES
|
.NOTES
|
||||||
- This module is based on CIS benchmarks.
|
- This module is based on CIS benchmarks.
|
||||||
- Governed by the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
|
- Governed by the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
The name of the worksheet within the Excel file to be processed.
|
The name of the worksheet within the Excel file to be processed.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS C:\> Remove-RowsWithEmptyCSVStatus -FilePath "C:\Reports\Report.xlsx" -WorksheetName "Sheet1"
|
PS C:\> Remove-RowsWithEmptyCSVStatus -FilePath "C:\Reports\Report.xlsx" -WorksheetName "Sheet1"
|
||||||
This command imports data from the "Sheet1" worksheet in the "Report.xlsx" file, removes rows where the 'CSV_Status' column is empty, and saves the filtered data to a new file named "Report-Filtered.xlsx" in the same directory.
|
This command imports data from the "Sheet1" worksheet in the "Report.xlsx" file, removes rows where the 'CSV_Status' column is empty, and saves the filtered data to a new file named "Report-Filtered.xlsx" in the same directory.
|
||||||
.NOTES
|
.NOTES
|
||||||
This function requires the ImportExcel module to be installed.
|
This function requires the ImportExcel module to be installed.
|
||||||
#>
|
#>
|
||||||
@@ -22,28 +22,21 @@ function Remove-RowsWithEmptyCSVStatus {
|
|||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[string]$WorksheetName
|
[string]$WorksheetName
|
||||||
)
|
)
|
||||||
|
|
||||||
# Import the Excel file
|
# Import the Excel file
|
||||||
$ExcelData = Import-Excel -Path $FilePath -WorksheetName $WorksheetName
|
$ExcelData = Import-Excel -Path $FilePath -WorksheetName $WorksheetName
|
||||||
|
|
||||||
# Check if CSV_Status column exists
|
# Check if CSV_Status column exists
|
||||||
if (-not $ExcelData.PSObject.Properties.Match("CSV_Status")) {
|
if (-not $ExcelData.PSObject.Properties.Match("CSV_Status")) {
|
||||||
throw "CSV_Status column not found in the worksheet."
|
throw "CSV_Status column not found in the worksheet."
|
||||||
}
|
}
|
||||||
|
|
||||||
# Filter rows where CSV_Status is not empty
|
# Filter rows where CSV_Status is not empty
|
||||||
$FilteredData = $ExcelData | Where-Object { $null -ne $_.CSV_Status -and $_.CSV_Status -ne '' }
|
$FilteredData = $ExcelData | Where-Object { $null -ne $_.CSV_Status -and $_.CSV_Status -ne '' }
|
||||||
|
|
||||||
# Get the original file name and directory
|
# Get the original file name and directory
|
||||||
$OriginalFileName = [System.IO.Path]::GetFileNameWithoutExtension($FilePath)
|
$OriginalFileName = [System.IO.Path]::GetFileNameWithoutExtension($FilePath)
|
||||||
$Directory = [System.IO.Path]::GetDirectoryName($FilePath)
|
$Directory = [System.IO.Path]::GetDirectoryName($FilePath)
|
||||||
|
|
||||||
# Create a new file name for the filtered data
|
# Create a new file name for the filtered data
|
||||||
$NewFileName = "$OriginalFileName-Filtered.xlsx"
|
$NewFileName = "$OriginalFileName-Filtered.xlsx"
|
||||||
$NewFilePath = Join-Path -Path $Directory -ChildPath $NewFileName
|
$NewFilePath = Join-Path -Path $Directory -ChildPath $NewFileName
|
||||||
|
|
||||||
# Export the filtered data to a new Excel file
|
# Export the filtered data to a new Excel file
|
||||||
$FilteredData | Export-Excel -Path $NewFilePath -WorksheetName $WorksheetName -Show
|
$FilteredData | Export-Excel -Path $NewFilePath -WorksheetName $WorksheetName -Show
|
||||||
|
|
||||||
Write-Output "Filtered Excel file created at $NewFilePath"
|
Write-Output "Filtered Excel file created at $NewFilePath"
|
||||||
}
|
}
|
@@ -1,27 +1,27 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Synchronizes and updates data in an Excel worksheet with new information from a CSV file, including audit dates.
|
Synchronizes and updates data in an Excel worksheet with new information from a CSV file, including audit dates.
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
The Sync-CISExcelAndCsvData function merges and updates data in a specified Excel worksheet from a CSV file. This includes adding or updating fields for connection status, details, failure reasons, and the date of the update. It's designed to ensure that the Excel document maintains a running log of changes over time, ideal for tracking remediation status and audit history.
|
The Sync-CISExcelAndCsvData function merges and updates data in a specified Excel worksheet from a CSV file. This includes adding or updating fields for connection status, details, failure reasons, and the date of the update. It's designed to ensure that the Excel document maintains a running log of changes over time, ideal for tracking remediation status and audit history.
|
||||||
.PARAMETER ExcelPath
|
.PARAMETER ExcelPath
|
||||||
Specifies the path to the Excel file to be updated. This parameter is mandatory.
|
Specifies the path to the Excel file to be updated. This parameter is mandatory.
|
||||||
.PARAMETER CsvPath
|
.PARAMETER CsvPath
|
||||||
Specifies the path to the CSV file containing new data. This parameter is mandatory.
|
Specifies the path to the CSV file containing new data. This parameter is mandatory.
|
||||||
.PARAMETER SheetName
|
.PARAMETER SheetName
|
||||||
Specifies the name of the worksheet in the Excel file where data will be merged and updated. This parameter is mandatory.
|
Specifies the name of the worksheet in the Excel file where data will be merged and updated. This parameter is mandatory.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> Sync-CISExcelAndCsvData -ExcelPath "path\to\excel.xlsx" -CsvPath "path\to\data.csv" -SheetName "AuditData"
|
PS> Sync-CISExcelAndCsvData -ExcelPath "path\to\excel.xlsx" -CsvPath "path\to\data.csv" -SheetName "AuditData"
|
||||||
Updates the 'AuditData' worksheet in 'excel.xlsx' with data from 'data.csv', adding new information and the date of the update.
|
Updates the 'AuditData' worksheet in 'excel.xlsx' with data from 'data.csv', adding new information and the date of the update.
|
||||||
.INPUTS
|
.INPUTS
|
||||||
System.String
|
System.String
|
||||||
The function accepts strings for file paths and worksheet names.
|
The function accepts strings for file paths and worksheet names.
|
||||||
.OUTPUTS
|
.OUTPUTS
|
||||||
None
|
None
|
||||||
The function directly updates the Excel file and does not output any objects.
|
The function directly updates the Excel file and does not output any objects.
|
||||||
.NOTES
|
.NOTES
|
||||||
- Ensure that the 'ImportExcel' module is installed and up to date to handle Excel file manipulations.
|
- Ensure that the 'ImportExcel' module is installed and up to date to handle Excel file manipulations.
|
||||||
- It is recommended to back up the Excel file before running this function to avoid accidental data loss.
|
- It is recommended to back up the Excel file before running this function to avoid accidental data loss.
|
||||||
- The CSV file should have columns that match expected headers like 'Connection', 'Details', 'FailureReason', and 'Status' for correct data mapping.
|
- The CSV file should have columns that match expected headers like 'Connection', 'Details', 'FailureReason', and 'Status' for correct data mapping.
|
||||||
.LINK
|
.LINK
|
||||||
https://criticalsolutionsnetwork.github.io/M365FoundationsCISReport/#Sync-CISExcelAndCsvData
|
https://criticalsolutionsnetwork.github.io/M365FoundationsCISReport/#Sync-CISExcelAndCsvData
|
||||||
#>
|
#>
|
||||||
|
Reference in New Issue
Block a user