74 Commits

Author SHA1 Message Date
Doug Rios
be0b6e0129 Merge pull request #156 from CriticalSolutionsNetwork/Bugfix--Fix-SPO-output-for-Get-SPOSite
fix: Fix SPO output for Get-SPOSite
2025-01-14 13:11:13 -06:00
DrIOS
642cdfe2ab fix: Fix SPO output for Get-SPOSite 2025-01-14 13:07:59 -06:00
Doug Rios
a8b76c7e16 Merge pull request #155 from CriticalSolutionsNetwork/Bugfix-Sharepoint-Online-Issue-from-EOY-2024
Bugfix sharepoint online issue from eoy 2024
2025-01-13 16:07:14 -06:00
DrIOS
fbf40fa98e add: method to avoid assembly already loaded error 2025-01-13 16:03:30 -06:00
DrIOS
f409e8a5f1 add: new method of verifying spo tenant for Connect-SPOService branch 2025-01-13 15:35:07 -06:00
DrIOS
c341279531 add: error handling to identify problematic step in connect function 2025-01-13 14:46:53 -06:00
DrIOS
6a8438bbe8 add: error handling to identify problematic step in connect function 2025-01-13 14:44:18 -06:00
DrIOS
87c635210d docs: Update Help 2024-08-04 16:03:14 -05:00
DrIOS
07592569b4 docs: Pull doc changes 2024-08-04 15:55:40 -05:00
Doug Rios
4b3a0b7505 Merge pull request #148 from CriticalSolutionsNetwork/Testing-Automations
Testing automations
2024-08-04 15:46:49 -05:00
DrIOS
042bf7b37c docs: update help docs 2024-08-04 15:44:12 -05:00
DrIOS
69ae64562f docs: update help docs 2024-08-04 15:40:50 -05:00
DrIOS
c64325e773 docs: update help docs 2024-08-04 15:34:28 -05:00
DrIOS
c341db53c5 docs: update help docs 2024-08-04 15:17:21 -05:00
DrIOS
2f5c653cc8 docs: Update CHANGELOG 2024-08-04 14:53:21 -05:00
DrIOS
00600123f3 docs: Update readme and html help 2024-08-04 14:50:58 -05:00
DrIOS
0cb1643341 docs: Update readme and html help 2024-08-04 14:47:45 -05:00
DrIOS
939980b087 docs: Update readme and html help 2024-08-04 14:29:42 -05:00
DrIOS
f375fdd5ef rename function 2024-08-04 14:13:35 -05:00
DrIOS
0ea930c708 rename function 2024-08-04 14:13:25 -05:00
Doug Rios
f9e3b5faed Merge pull request #149 from CriticalSolutionsNetwork/main
Update README.md
2024-08-04 13:56:38 -05:00
Doug Rios
4613d592d1 Update README.md 2024-08-04 13:54:55 -05:00
DrIOS
da968db3e2 change: refactor Get-CISSpoOutput to support application auth using Pnp Powershell 2024-08-04 13:51:29 -05:00
DrIOS
357f284d08 add: test number to error 2024-08-04 13:49:58 -05:00
DrIOS
9e3058add4 add: test number to Get-TestError output 2024-08-04 13:49:13 -05:00
DrIOS
d7d16ff0b5 add: App Authentication test 2024-08-03 18:52:46 -05:00
DrIOS
45eb961554 Fix: Vaugue parameter name 2024-08-03 11:43:42 -05:00
DrIOS
686e805f6a Fix: Vaugue parameter name 2024-08-03 11:42:59 -05:00
DrIOS
63edc13261 fix: Export original and all tests 2024-08-03 11:29:15 -05:00
DrIOS
9508130ddd fix: compatibility version 2024-08-03 11:28:46 -05:00
DrIOS
db73d755ed fix: Output suppression 2024-08-01 21:14:56 -05:00
Doug Rios
37e2b70ba4 Merge pull request #146 from CriticalSolutionsNetwork/Fix-pw-notification-test
Fix pw notification test
2024-07-23 08:17:32 -05:00
DrIOS
8acae46b98 docs: Update CHANGELOG 2024-07-23 07:53:00 -05:00
DrIOS
1fd460c84d fix: notification window for 1.3.1 2024-07-23 07:51:15 -05:00
Doug Rios
9f28c976ce Merge pull request #144 from CriticalSolutionsNetwork/Test-Help
docs: Update Help Wiki
2024-07-07 17:45:21 -05:00
DrIOS
1ec287031c docs: Update Help Wiki 2024-07-07 17:43:25 -05:00
DrIOS
de89312352 docs: Update Help Wiki 2024-07-07 17:41:04 -05:00
Doug Rios
1717b60891 Merge pull request #142 from CriticalSolutionsNetwork/Revert-and-refactor-1.3.3,6.1.2,6.1.3
Revert and refactor 1.3.3,2.1.4,6.1.2,6.1.3
2024-07-07 17:24:24 -05:00
DrIOS
6624bde267 docs: Update CHANGELOG 2024-07-07 17:21:40 -05:00
DrIOS
e4277afdb7 docs: Update Help README/HTML 2024-07-07 17:15:26 -05:00
DrIOS
7688071899 docs: Update Markdown 2024-07-07 17:15:05 -05:00
DrIOS
e1ab050e69 docs: Update Comment Help 2024-07-07 17:00:42 -05:00
DrIOS
7226afd198 docs: Update Comment Help 2024-07-07 16:42:55 -05:00
DrIOS
337a21bc7d docs: Update Comment Help 2024-07-07 16:37:38 -05:00
DrIOS
14ed9f6598 docs: Update Comment Help 2024-07-07 16:32:50 -05:00
DrIOS
5ddcd4466e docs: Update CHANGELOG 2024-07-07 16:21:05 -05:00
DrIOS
228c58cef3 fix: Safe Attachments logic 2024-07-07 16:18:43 -05:00
DrIOS
fe04175798 fix: formatting of 1.3.3 here string 2024-07-07 13:06:19 -05:00
DrIOS
8197187f70 docs: Update CHANGELOG 2024-07-07 13:02:11 -05:00
DrIOS
f830bdf2f0 docs: Update testfile 2024-07-07 12:56:02 -05:00
DrIOS
e86c61d221 change: Get-Action Testing-Refactor export 2024-07-07 12:48:39 -05:00
DrIOS
17647d7180 change: Get-Action Testing-DONE 2024-07-07 12:18:38 -05:00
DrIOS
d941459ac0 change: Get-Action Testing 2024-07-07 12:11:06 -05:00
DrIOS
4557c1806f change: Get-Action Testing 2024-07-07 12:01:34 -05:00
DrIOS
fcaebf1db1 change: Get-Action Testing 2024-07-07 11:58:16 -05:00
DrIOS
ff1162f962 change: Test-ExternalSharingCalendars reverted to simple test 2024-07-07 10:25:15 -05:00
DrIOS
f91af6e725 change: Test-ExternalSharingCalendars reverted to simple test 2024-07-07 10:24:32 -05:00
Doug Rios
904e36c376 Merge pull request #140 from CriticalSolutionsNetwork/131-formatting-spo
131 formatting spo
2024-07-02 10:04:19 -05:00
DrIOS
d68ae22982 docs: Update CHANGELOG 2024-07-02 10:02:55 -05:00
DrIOS
50c94485e7 fix: Manual rebase export 2024-07-02 10:00:26 -05:00
DrIOS
a80e26f089 fix: Manual rebase export 2024-07-02 09:54:30 -05:00
DrIOS
5d11b46d96 fix: SPO formatting and output 2024-07-02 09:47:06 -05:00
DrIOS
5ef32eb4b8 fix: up to 7.2.6 SPO formatting and output 2024-07-02 09:00:54 -05:00
DrIOS
0e2e779c82 fix: up to 7.2.6 SPO formatting and output 2024-07-02 09:00:43 -05:00
Doug Rios
1240f74450 Merge pull request #139 from CriticalSolutionsNetwork/138-add-hash-computation-to-file-output-of-export-function-and-compress-into-archive
138 add hash computation to file output of export function and compress into archive
2024-07-01 13:22:15 -05:00
DrIOS
063124eef3 docs: Update build help/CHANGELOG 2024-07-01 13:19:44 -05:00
DrIOS
14f3889378 docs: Update Help/WikiFiles/HTML Help 2024-07-01 13:18:54 -05:00
DrIOS
3790ec00de add: Zip and hash computation to function 2024-07-01 13:12:56 -05:00
Doug Rios
c1171ddca5 Merge pull request #137 from CriticalSolutionsNetwork/132-formatting-microsoft-graph
fix: MgGraph commands formatting
2024-06-30 15:37:02 -05:00
Douglas Rios
fc7c8ec88f docs: Update CHANGELOG 2024-06-30 15:34:58 -05:00
Douglas Rios
2fc814205d fix: MgGraph commands formatting 2024-06-30 15:32:05 -05:00
Doug Rios
7309925e89 Merge pull request #136 from CriticalSolutionsNetwork/135-add-parameter-validation-to-new-parameters
135 add parameter validation to new parameters
2024-06-30 12:55:10 -05:00
DrIOS
5637855c8b docs: Update CHANGELOG 2024-06-30 12:53:21 -05:00
DrIOS
ac98307ed1 fix: parameter validation for new parameters in Invoke-M365SecurityAudit function 2024-06-30 12:53:07 -05:00
71 changed files with 3180 additions and 1828 deletions

1
.gitignore vendored
View File

@@ -17,3 +17,4 @@ node_modules
package-lock.json package-lock.json
Aligned.xlsx Aligned.xlsx
test-gh1.ps1 test-gh1.ps1
ModdedModules/*

View File

@@ -4,6 +4,94 @@ The format is based on and uses the types of changes according to [Keep a Change
## [Unreleased] ## [Unreleased]
### Fixed
- Get-SPOSite command to return all but voided output for no code runs (Ex: PowerAutomate)
## [0.1.27] - 2025-01-13
### Added
- Added additional error handling to connect function to identify problematic steps when they occur.
- Added new method of verifying spo tenant for Connect-SPOService branch of connect function.
- Added method to avoid "assembly already loaded" error in PNP Powershell function on first run, subsequent runs in the same session will still throw the error.
## [0.1.26] - 2024-08-04
### Added
- Added `New-M365SecurityAuditAuthObject` function to create a new authentication object for the security audit for app-based authentication.
### Changed
- Changed authentication options to include parameter for authenticating with a certificate.
- Changed verbose output to ensure methods for suppressing all forms of output are available.
## [0.1.25] - 2024-07-23
### Fixed
- Fixed test 1.3.1 as notification window for password expiration is no longer required.
## [0.1.24] - 2024-07-07
### Added
- New private function `Get-AuditMailboxDetail` for 6.1.2 and 6.1.3 tests to get the action details for the test.
### Changed
- Changed `Get-Action` function to include both dictionaries.
### Fixed
- Fixed Test 1.3.3 to be the simpler version of the test while including output to check for current users sharing calendars.
- Safe Attachments logic and added `$DomainName` as input to 2.1.4 to test main policy.
### Docs
- Updated `about_M365FoundationsCISReport` help file with new functions and changes.
- Updated `Invoke-M365SecurityAudit` help file with examples.
- Updated `Export-M365SecurityAudit` help file with examples.
## [0.1.23] - 2024-07-02
# Fixed
- SPO tests formatting and output.
## [0.1.22] - 2024-07-01
### Added
- Added hash and compress steps to `Export-M365SecurityAuditTable` function.
## [0.1.21] - 2024-07-01
### Fixed
- SPO tests formatting and output.
## [0.1.22] - 2024-07-01
### Added
- Added hash and compress steps to `Export-M365SecurityAuditTable` function.
## [0.1.21] - 2024-07-01
### Fixed
- Formatting for MgGraph tests.
## [0.1.20] - 2024-06-30
### Fixed
- Fixed parameter validation for new parameters in `Invoke-M365SecurityAudit` function
## [0.1.19] - 2024-06-30
### Added ### Added
- Added `ApprovedCloudStorageProviders` parameter to `Invoke-M365SecurityAudit` to allow for testing of approved cloud storage providers for 8.1.1. - Added `ApprovedCloudStorageProviders` parameter to `Invoke-M365SecurityAudit` to allow for testing of approved cloud storage providers for 8.1.1.

View File

@@ -1,5 +1,6 @@
# M365FoundationsCISReport Module # M365FoundationsCISReport Module
[![PSScriptAnalyzer](https://github.com/CriticalSolutionsNetwork/M365FoundationsCISReport/actions/workflows/powershell.yml/badge.svg)](https://github.com/CriticalSolutionsNetwork/M365FoundationsCISReport/actions/workflows/powershell.yml)
[![pages-build-deployment](https://github.com/CriticalSolutionsNetwork/M365FoundationsCISReport/actions/workflows/pages/pages-build-deployment/badge.svg)](https://github.com/CriticalSolutionsNetwork/M365FoundationsCISReport/actions/workflows/pages/pages-build-deployment)
## License ## License
This PowerShell module is based on CIS benchmarks and is distributed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. This means: This PowerShell module is based on CIS benchmarks and is distributed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. This means:
@@ -11,83 +12,87 @@ This PowerShell module is based on CIS benchmarks and is distributed under the C
For full license details, please visit [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-nc-sa/4.0/deed.en). For full license details, please visit [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-nc-sa/4.0/deed.en).
[Register for and download CIS Benchmarks](https://www.cisecurity.org/cis-benchmarks) [Register for and download CIS Benchmarks](https://www.cisecurity.org/cis-benchmarks)
# Table of Contents
1. [Invoke-M365SecurityAudit](#Invoke-M365SecurityAudit)
2. [Export-M365SecurityAuditTable](#Export-M365SecurityAuditTable)
3. [Get-AdminRoleUserLicense](#Get-AdminRoleUserLicense)
4. [Get-MFAStatus](#Get-MFAStatus)
5. [Grant-M365SecurityAuditConsent](#Grant-M365SecurityAuditConsent)
6. [New-M365SecurityAuditAuthObject](#New-M365SecurityAuditAuthObject)
7. [Remove-RowsWithEmptyCSVStatus](#Remove-RowsWithEmptyCSVStatus)
8. [Sync-CISExcelAndCsvData](#Sync-CISExcelAndCsvData)
## Module Dependencies
The `M365FoundationsCISReport` module relies on several other PowerShell modules to perform its operations. The default run ensures these modules are installed with the specified versions. Use -NoModuleCheck to skip this step if you have installed the required modules previously and would like to suppress any output for automated runs.
### Required Modules for Audit Functions
Default modules used for audit functions:
- **ExchangeOnlineManagement**
- Required Version: `3.3.0`
- **Microsoft.Graph**
- Required Version: `2.4.0`
- **PnP.PowerShell** (Optional, if PnP App authentication is used for SharePoint Online)
- Required Version: `2.5.0`
- **Microsoft.Online.SharePoint.PowerShell** (If PnP authentication is not used (Default) )
- Required Version: `16.0.24009.12000`
- **MicrosoftTeams**
- Required Version: `5.5.0`
- **ImportExcel** (If importing or exporting Excel files)
- Required Version: `7.8.9`
# EXAMPLES
## Invoke-M365SecurityAudit
### Synopsis
Invokes a security audit for Microsoft 365 environments.
### Syntax
```powershell ```powershell
# Example 1: Performing a security audit based on CIS benchmarks
$auditResults = Invoke-M365SecurityAudit -TenantAdminUrl "https://contoso-admin.sharepoint.com"
$auditResults = Invoke-M365SecurityAudit -TenantAdminUrl "https://contoso-admin.sharepoint.com" -DomainName "contoso.com" -ApprovedCloudStorageProviders "DropBox" -ApprovedFederatedDomains "northwind.com"
# Suppressed output for automated runs
$auditResults = Invoke-M365SecurityAudit -TenantAdminUrl "https://contoso-admin.sharepoint.com" -NoModuleCheck -NoModuleCheck -DoNotConfirmConnections -Confirm:$false
Invoke-M365SecurityAudit -TenantAdminUrl <String> -DomainName <String> [-DoNotConnect] [-DoNotDisconnect] [-NoModuleCheck] [-WhatIf] [-Confirm] [<CommonParameters>] # Example 2: Exporting a security audit and it's nested tables to zipped CSV files
Export-M365SecurityAuditTable -AuditResults $auditResults -ExportPath "C:\temp" -ExportOriginalTests -ExportNestedTables
# Output Ex: 2024.07.07_14.55.55_M365FoundationsAudit_368B2E2F.zip
Invoke-M365SecurityAudit -TenantAdminUrl <String> -DomainName <String> [-ELevel <String>] [-ProfileLevel <String>] [-DoNotConnect] [-DoNotDisconnect] [-NoModuleCheck] [-WhatIf] [-Confirm] [<CommonParameters>] # Example 3: Retrieving licenses for users in administrative roles
Get-AdminRoleUserLicense
Invoke-M365SecurityAudit -TenantAdminUrl <String> -DomainName <String> [-IncludeIG1] [-DoNotConnect] [-DoNotDisconnect] [-NoModuleCheck] [-WhatIf] [-Confirm] [<CommonParameters>] # Example 4: Getting MFA status of users
Get-MFAStatus -UserId "user@domain.com"
Invoke-M365SecurityAudit -TenantAdminUrl <String> -DomainName <String> [-IncludeIG2] [-DoNotConnect] [-DoNotDisconnect] [-NoModuleCheck] [-WhatIf] [-Confirm] [<CommonParameters>]
Invoke-M365SecurityAudit -TenantAdminUrl <String> -DomainName <String> [-IncludeIG3] [-DoNotConnect] [-DoNotDisconnect] [-NoModuleCheck] [-WhatIf] [-Confirm] [<CommonParameters>]
Invoke-M365SecurityAudit -TenantAdminUrl <String> -DomainName <String> [-IncludeRecommendation <String[]>] [-DoNotConnect] [-DoNotDisconnect] [-NoModuleCheck] [-WhatIf] [-Confirm] [<CommonParameters>]
Invoke-M365SecurityAudit -TenantAdminUrl <String> -DomainName <String> [-SkipRecommendation <String[]>] [-DoNotConnect] [-DoNotDisconnect] [-NoModuleCheck] [-WhatIf] [-Confirm] [<CommonParameters>]
# Example 5: Removing rows with empty status values from a CSV file
Remove-RowsWithEmptyCSVStatus -FilePath "C:\Reports\Report.xlsx" -WorksheetName "Sheet1"
# Example 6: Synchronizing CIS benchmark data with audit results
Sync-CISExcelAndCsvData -ExcelPath "path\to\excel.xlsx" -CsvPath "path\to\data.csv" -SheetName "Combined Profiles"
# Example 7: Granting Microsoft Graph permissions to the auditor
Grant-M365SecurityAuditConsent -UserPrincipalNameForConsent 'user@example.com'
# Example 8: (PowerShell 7.x Only) Creating a new authentication object for the security audit for app-based authentication.
$authParams = New-M365SecurityAuditAuthObject `
-ClientCertThumbPrint "ABCDEF1234567890ABCDEF1234567890ABCDEF12" `
-ClientId "12345678-1234-1234-1234-123456789012" `
-TenantId "12345678-1234-1234-1234-123456789012" `
-OnMicrosoftUrl "yourcompany.onmicrosoft.com" `
-SpAdminUrl "https://yourcompany-admin.sharepoint.com"
Invoke-M365SecurityAudit -AuthParams $authParams -TenantAdminUrl "https://yourcompany-admin.sharepoint.com"
``` ```
### Parameters
| Name | Alias | Description | Required? | Pipeline Input | Default Value |
| - | - | - | - | - | - |
| <nobr>TenantAdminUrl</nobr> | | The URL of the tenant admin. This parameter is mandatory. | true | false | |
| <nobr>DomainName</nobr> | | The domain name of the Microsoft 365 environment. This parameter is mandatory. | true | false | |
| <nobr>ELevel</nobr> | | Specifies the E-Level \(E3 or E5\) for the audit. This parameter is optional and can be combined with the ProfileLevel parameter. | false | false | |
| <nobr>ProfileLevel</nobr> | | Specifies the profile level \(L1 or L2\) for the audit. This parameter is optional and can be combined with the ELevel parameter. | false | false | |
| <nobr>IncludeIG1</nobr> | | If specified, includes tests where IG1 is true. | false | false | False |
| <nobr>IncludeIG2</nobr> | | If specified, includes tests where IG2 is true. | false | false | False |
| <nobr>IncludeIG3</nobr> | | If specified, includes tests where IG3 is true. | false | false | False |
| <nobr>IncludeRecommendation</nobr> | | Specifies specific recommendations to include in the audit. Accepts an array of recommendation numbers. | false | false | |
| <nobr>SkipRecommendation</nobr> | | Specifies specific recommendations to exclude from the audit. Accepts an array of recommendation numbers. | false | false | |
| <nobr>DoNotConnect</nobr> | | If specified, the cmdlet will not establish a connection to Microsoft 365 services. | false | false | False |
| <nobr>DoNotDisconnect</nobr> | | If specified, the cmdlet will not disconnect from Microsoft 365 services after execution. | false | false | False |
| <nobr>NoModuleCheck</nobr> | | If specified, the cmdlet will not check for the presence of required modules. | false | false | False |
| <nobr>WhatIf</nobr> | wi | | false | false | |
| <nobr>Confirm</nobr> | cf | | false | false | |
### Inputs
- None. You cannot pipe objects to Invoke-M365SecurityAudit.
### Outputs # NOTE
- CISAuditResult\\[\] The cmdlet returns an array of CISAuditResult objects representing the results of the security audit. Ensure that you have the necessary permissions and administrative roles in your Microsoft 365 environment to run these cmdlets. Proper configuration and setup are required for accurate audit results.
### Note # TROUBLESHOOTING NOTE
This module is based on CIS benchmarks and is governed by the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. For more details, visit: https://creativecommons.org/licenses/by-nc-sa/4.0/deed.en If you encounter any issues while using the cmdlets, ensure that your environment meets the module prerequisites. Check for any updates or patches that may address known bugs. For issues related to specific cmdlets, refer to the individual help files for troubleshooting tips.
### Examples # SEE ALSO
**EXAMPLE 1** - [CIS Benchmarks](https://www.cisecurity.org/cis-benchmarks/)
```powershell - [Microsoft 365 Security Documentation](https://docs.microsoft.com/en-us/microsoft-365/security/)
Invoke-M365SecurityAudit -TenantAdminUrl "https://contoso-admin.sharepoint.com" -DomainName "contoso.com" -ELevel "E5" -ProfileLevel "L1" - [PowerShell Documentation](https://docs.microsoft.com/en-us/powershell/)
```
Performs a security audit for the E5 level and L1 profile in the specified Microsoft 365 environment.
**EXAMPLE 2**
```powershell
Invoke-M365SecurityAudit -TenantAdminUrl "https://contoso-admin.sharepoint.com" -DomainName "contoso.com" -IncludeIG1
```
Performs an audit including all tests where IG1 is true.
**EXAMPLE 3**
```powershell
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.
**EXAMPLE 4**
```powershell
$auditResults = Invoke-M365SecurityAudit -TenantAdminUrl "https://contoso-admin.sharepoint.com" -DomainName "contoso.com"
PS> $auditResults | Export-Csv -Path "auditResults.csv" -NoTypeInformation
```
Captures the audit results into a variable and exports them to a CSV file.
### Links
- [Online Version: [GitHub Repository URL]](#Online Version: [GitHub Repository URL])

BIN
README.md

Binary file not shown.

Binary file not shown.

View File

@@ -15,24 +15,27 @@ Exports M365 security audit results to a CSV file or outputs a specific test res
### OutputObjectFromAuditResultsSingle ### OutputObjectFromAuditResultsSingle
``` ```
Export-M365SecurityAuditTable [-AuditResults] <CISAuditResult[]> [-OutputTestNumber] <String> Export-M365SecurityAuditTable [-AuditResults] <CISAuditResult[]> [-OutputTestNumber] <String>
[<CommonParameters>] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
``` ```
### ExportAllResultsFromAuditResults ### ExportAllResultsFromAuditResults
``` ```
Export-M365SecurityAuditTable [-AuditResults] <CISAuditResult[]> [-ExportAllTests] -ExportPath <String> Export-M365SecurityAuditTable [-AuditResults] <CISAuditResult[]> [-ExportNestedTables] -ExportPath <String>
[-ExportOriginalTests] [-ExportToExcel] [<CommonParameters>] [-ExportOriginalTests] [-ExportToExcel] [-Prefix <String>] [-ProgressAction <ActionPreference>] [-WhatIf]
[-Confirm] [<CommonParameters>]
``` ```
### OutputObjectFromCsvSingle ### OutputObjectFromCsvSingle
``` ```
Export-M365SecurityAuditTable [-CsvPath] <String> [-OutputTestNumber] <String> [<CommonParameters>] Export-M365SecurityAuditTable [-CsvPath] <String> [-OutputTestNumber] <String>
[-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
``` ```
### ExportAllResultsFromCsv ### ExportAllResultsFromCsv
``` ```
Export-M365SecurityAuditTable [-CsvPath] <String> [-ExportAllTests] -ExportPath <String> [-ExportOriginalTests] Export-M365SecurityAuditTable [-CsvPath] <String> [-ExportNestedTables] -ExportPath <String>
[-ExportToExcel] [<CommonParameters>] [-ExportOriginalTests] [-ExportToExcel] [-Prefix <String>] [-ProgressAction <ActionPreference>] [-WhatIf]
[-Confirm] [<CommonParameters>]
``` ```
## DESCRIPTION ## DESCRIPTION
@@ -125,8 +128,8 @@ Accept pipeline input: False
Accept wildcard characters: False Accept wildcard characters: False
``` ```
### -ExportAllTests ### -ExportNestedTables
Switch to export all test results. Switch to export all test results. When specified, all test results are exported to the specified path.
```yaml ```yaml
Type: SwitchParameter Type: SwitchParameter
@@ -163,7 +166,7 @@ Type: SwitchParameter
Parameter Sets: ExportAllResultsFromAuditResults, ExportAllResultsFromCsv Parameter Sets: ExportAllResultsFromAuditResults, ExportAllResultsFromCsv
Aliases: Aliases:
Required: True Required: False
Position: Named Position: Named
Default value: False Default value: False
Accept pipeline input: False Accept pipeline input: False
@@ -185,15 +188,77 @@ Accept pipeline input: False
Accept wildcard characters: False Accept wildcard characters: False
``` ```
### -Prefix
Add Prefix to filename after date when outputting to excel or csv.
Validate that the count of letters in the prefix is less than 5.
```yaml
Type: String
Parameter Sets: ExportAllResultsFromAuditResults, ExportAllResultsFromCsv
Aliases:
Required: False
Position: Named
Default value: Corp
Accept pipeline input: False
Accept wildcard characters: False
```
### -WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Confirm
Prompts you for confirmation before running the cmdlet.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -ProgressAction
{{ Fill ProgressAction Description }}
```yaml
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters ### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS ## INPUTS
### [CISAuditResult[]], [string] ### [CISAuditResult[]] - An array of CISAuditResult objects.
### [string] - A path to a CSV file.
## OUTPUTS ## OUTPUTS
### [PSCustomObject] ### [PSCustomObject] - A custom object containing the path to the zip file and its hash.
## NOTES ## NOTES
## RELATED LINKS ## RELATED LINKS

View File

@@ -1,4 +1,4 @@
--- ---
external help file: M365FoundationsCISReport-help.xml external help file: M365FoundationsCISReport-help.xml
Module Name: M365FoundationsCISReport Module Name: M365FoundationsCISReport
online version: https://criticalsolutionsnetwork.github.io/M365FoundationsCISReport/#Get-AdminRoleUserLicense online version: https://criticalsolutionsnetwork.github.io/M365FoundationsCISReport/#Get-AdminRoleUserLicense
@@ -13,7 +13,7 @@ Retrieves user licenses and roles for administrative accounts from Microsoft 365
## SYNTAX ## SYNTAX
``` ```
Get-AdminRoleUserLicense [-SkipGraphConnection] [<CommonParameters>] Get-AdminRoleUserLicense [-SkipGraphConnection] [-ProgressAction <ActionPreference>] [<CommonParameters>]
``` ```
## DESCRIPTION ## DESCRIPTION
@@ -54,6 +54,21 @@ Accept pipeline input: False
Accept wildcard characters: False Accept wildcard characters: False
``` ```
### -ProgressAction
{{ Fill ProgressAction Description }}
```yaml
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters ### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).

View File

@@ -13,7 +13,8 @@ Retrieves the MFA (Multi-Factor Authentication) status for Azure Active Director
## SYNTAX ## SYNTAX
``` ```
Get-MFAStatus [[-UserId] <String>] [-SkipMSOLConnectionChecks] [<CommonParameters>] Get-MFAStatus [[-UserId] <String>] [-SkipMSOLConnectionChecks] [-ProgressAction <ActionPreference>]
[<CommonParameters>]
``` ```
## DESCRIPTION ## DESCRIPTION
@@ -67,6 +68,21 @@ Accept pipeline input: False
Accept wildcard characters: False Accept wildcard characters: False
``` ```
### -ProgressAction
{{ Fill ProgressAction Description }}
```yaml
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters ### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).

View File

@@ -14,7 +14,8 @@ Grants Microsoft Graph permissions for an auditor.
``` ```
Grant-M365SecurityAuditConsent [-UserPrincipalNameForConsent] <String> [-SkipGraphConnection] Grant-M365SecurityAuditConsent [-UserPrincipalNameForConsent] <String> [-SkipGraphConnection]
[-SkipModuleCheck] [-SuppressRevertOutput] [-DoNotDisconnect] [-WhatIf] [-Confirm] [<CommonParameters>] [-SkipModuleCheck] [-SuppressRevertOutput] [-DoNotDisconnect] [-ProgressAction <ActionPreference>] [-WhatIf]
[-Confirm] [<CommonParameters>]
``` ```
## DESCRIPTION ## DESCRIPTION
@@ -146,6 +147,21 @@ Accept pipeline input: False
Accept wildcard characters: False Accept wildcard characters: False
``` ```
### -ProgressAction
{{ Fill ProgressAction Description }}
```yaml
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters ### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).

View File

@@ -16,14 +16,16 @@ Invokes a security audit for Microsoft 365 environments.
``` ```
Invoke-M365SecurityAudit [-TenantAdminUrl <String>] [-DomainName <String>] Invoke-M365SecurityAudit [-TenantAdminUrl <String>] [-DomainName <String>]
[-ApprovedCloudStorageProviders <String[]>] [-ApprovedFederatedDomains <String[]>] [-DoNotConnect] [-ApprovedCloudStorageProviders <String[]>] [-ApprovedFederatedDomains <String[]>] [-DoNotConnect]
[-DoNotDisconnect] [-NoModuleCheck] [-DoNotConfirmConnections] [-WhatIf] [-Confirm] [<CommonParameters>] [-DoNotDisconnect] [-NoModuleCheck] [-DoNotConfirmConnections] [-AuthParams <CISAuthenticationParameters>]
[-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
``` ```
### ELevelFilter ### ELevelFilter
``` ```
Invoke-M365SecurityAudit [-TenantAdminUrl <String>] [-DomainName <String>] -ELevel <String> Invoke-M365SecurityAudit [-TenantAdminUrl <String>] [-DomainName <String>] -ELevel <String>
-ProfileLevel <String> [-ApprovedCloudStorageProviders <String[]>] [-ApprovedFederatedDomains <String[]>] -ProfileLevel <String> [-ApprovedCloudStorageProviders <String[]>] [-ApprovedFederatedDomains <String[]>]
[-DoNotConnect] [-DoNotDisconnect] [-NoModuleCheck] [-DoNotConfirmConnections] [-WhatIf] [-Confirm] [-DoNotConnect] [-DoNotDisconnect] [-NoModuleCheck] [-DoNotConfirmConnections]
[-AuthParams <CISAuthenticationParameters>] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm]
[<CommonParameters>] [<CommonParameters>]
``` ```
@@ -31,35 +33,40 @@ Invoke-M365SecurityAudit [-TenantAdminUrl <String>] [-DomainName <String>] -ELev
``` ```
Invoke-M365SecurityAudit [-TenantAdminUrl <String>] [-DomainName <String>] [-IncludeIG1] Invoke-M365SecurityAudit [-TenantAdminUrl <String>] [-DomainName <String>] [-IncludeIG1]
[-ApprovedCloudStorageProviders <String[]>] [-ApprovedFederatedDomains <String[]>] [-DoNotConnect] [-ApprovedCloudStorageProviders <String[]>] [-ApprovedFederatedDomains <String[]>] [-DoNotConnect]
[-DoNotDisconnect] [-NoModuleCheck] [-DoNotConfirmConnections] [-WhatIf] [-Confirm] [<CommonParameters>] [-DoNotDisconnect] [-NoModuleCheck] [-DoNotConfirmConnections] [-AuthParams <CISAuthenticationParameters>]
[-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
``` ```
### IG2Filter ### IG2Filter
``` ```
Invoke-M365SecurityAudit [-TenantAdminUrl <String>] [-DomainName <String>] [-IncludeIG2] Invoke-M365SecurityAudit [-TenantAdminUrl <String>] [-DomainName <String>] [-IncludeIG2]
[-ApprovedCloudStorageProviders <String[]>] [-ApprovedFederatedDomains <String[]>] [-DoNotConnect] [-ApprovedCloudStorageProviders <String[]>] [-ApprovedFederatedDomains <String[]>] [-DoNotConnect]
[-DoNotDisconnect] [-NoModuleCheck] [-DoNotConfirmConnections] [-WhatIf] [-Confirm] [<CommonParameters>] [-DoNotDisconnect] [-NoModuleCheck] [-DoNotConfirmConnections] [-AuthParams <CISAuthenticationParameters>]
[-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
``` ```
### IG3Filter ### IG3Filter
``` ```
Invoke-M365SecurityAudit [-TenantAdminUrl <String>] [-DomainName <String>] [-IncludeIG3] Invoke-M365SecurityAudit [-TenantAdminUrl <String>] [-DomainName <String>] [-IncludeIG3]
[-ApprovedCloudStorageProviders <String[]>] [-ApprovedFederatedDomains <String[]>] [-DoNotConnect] [-ApprovedCloudStorageProviders <String[]>] [-ApprovedFederatedDomains <String[]>] [-DoNotConnect]
[-DoNotDisconnect] [-NoModuleCheck] [-DoNotConfirmConnections] [-WhatIf] [-Confirm] [<CommonParameters>] [-DoNotDisconnect] [-NoModuleCheck] [-DoNotConfirmConnections] [-AuthParams <CISAuthenticationParameters>]
[-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
``` ```
### RecFilter ### RecFilter
``` ```
Invoke-M365SecurityAudit [-TenantAdminUrl <String>] [-DomainName <String>] -IncludeRecommendation <String[]> Invoke-M365SecurityAudit [-TenantAdminUrl <String>] [-DomainName <String>] -IncludeRecommendation <String[]>
[-ApprovedCloudStorageProviders <String[]>] [-ApprovedFederatedDomains <String[]>] [-DoNotConnect] [-ApprovedCloudStorageProviders <String[]>] [-ApprovedFederatedDomains <String[]>] [-DoNotConnect]
[-DoNotDisconnect] [-NoModuleCheck] [-DoNotConfirmConnections] [-WhatIf] [-Confirm] [<CommonParameters>] [-DoNotDisconnect] [-NoModuleCheck] [-DoNotConfirmConnections] [-AuthParams <CISAuthenticationParameters>]
[-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
``` ```
### SkipRecFilter ### SkipRecFilter
``` ```
Invoke-M365SecurityAudit [-TenantAdminUrl <String>] [-DomainName <String>] -SkipRecommendation <String[]> Invoke-M365SecurityAudit [-TenantAdminUrl <String>] [-DomainName <String>] -SkipRecommendation <String[]>
[-ApprovedCloudStorageProviders <String[]>] [-ApprovedFederatedDomains <String[]>] [-DoNotConnect] [-ApprovedCloudStorageProviders <String[]>] [-ApprovedFederatedDomains <String[]>] [-DoNotConnect]
[-DoNotDisconnect] [-NoModuleCheck] [-DoNotConfirmConnections] [-WhatIf] [-Confirm] [<CommonParameters>] [-DoNotDisconnect] [-NoModuleCheck] [-DoNotConfirmConnections] [-AuthParams <CISAuthenticationParameters>]
[-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
``` ```
## DESCRIPTION ## DESCRIPTION
@@ -395,6 +402,21 @@ Accept pipeline input: False
Accept wildcard characters: False Accept wildcard characters: False
``` ```
### -AuthParams
Specifies an authentication object containing parameters for application-based authentication. If provided, this will be used for connecting to services.
```yaml
Type: CISAuthenticationParameters
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -WhatIf ### -WhatIf
Shows what would happen if the cmdlet runs. Shows what would happen if the cmdlet runs.
The cmdlet is not run. The cmdlet is not run.
@@ -426,6 +448,21 @@ Accept pipeline input: False
Accept wildcard characters: False Accept wildcard characters: False
``` ```
### -ProgressAction
{{ Fill ProgressAction Description }}
```yaml
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters ### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).

View File

@@ -26,6 +26,9 @@ Grants Microsoft Graph permissions for an auditor.
### [Invoke-M365SecurityAudit](Invoke-M365SecurityAudit) ### [Invoke-M365SecurityAudit](Invoke-M365SecurityAudit)
Invokes a security audit for Microsoft 365 environments. Invokes a security audit for Microsoft 365 environments.
### [New-M365SecurityAuditAuthObject](New-M365SecurityAuditAuthObject)
Creates a new CISAuthenticationParameters object for Microsoft 365 authentication.
### [Remove-RowsWithEmptyCSVStatus](Remove-RowsWithEmptyCSVStatus) ### [Remove-RowsWithEmptyCSVStatus](Remove-RowsWithEmptyCSVStatus)
Removes rows from an Excel worksheet where the 'CSV_Status' column is empty and saves the result to a new file. Removes rows from an Excel worksheet where the 'CSV_Status' column is empty and saves the result to a new file.

View File

@@ -0,0 +1,149 @@
---
external help file: M365FoundationsCISReport-help.xml
Module Name: M365FoundationsCISReport
online version:
schema: 2.0.0
---
# New-M365SecurityAuditAuthObject
## SYNOPSIS
Creates a new CISAuthenticationParameters object for Microsoft 365 authentication.
## SYNTAX
```
New-M365SecurityAuditAuthObject [-ClientCertThumbPrint] <String> [-ClientId] <String> [-TenantId] <String>
[-OnMicrosoftUrl] <String> [-SpAdminUrl] <String> [-ProgressAction <ActionPreference>] [<CommonParameters>]
```
## DESCRIPTION
The New-M365SecurityAuditAuthObject function constructs a new CISAuthenticationParameters object
containing the necessary credentials and URLs for authenticating to various Microsoft 365 services.
It validates input parameters to ensure they conform to expected formats and length requirements.
An app registration in Azure AD with the required permissions to EXO, SPO, MSTeams and MgGraph is needed.
## EXAMPLES
### EXAMPLE 1
```
$authParams = New-M365SecurityAuditAuthObject -ClientCertThumbPrint "ABCDEF1234567890ABCDEF1234567890ABCDEF12" `
-ClientId "12345678-1234-1234-1234-123456789012" `
-TenantId "12345678-1234-1234-1234-123456789012" `
-OnMicrosoftUrl "yourcompany.onmicrosoft.com" `
-SpAdminUrl "https://yourcompany-admin.sharepoint.com"
Creates a new CISAuthenticationParameters object with the specified credentials and URLs, validating each parameter's format and length.
```
## PARAMETERS
### -ClientCertThumbPrint
The thumbprint of the client certificate used for authentication.
It must be a 40-character hexadecimal string.
This certificate is used to authenticate the application in Azure AD.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -ClientId
The Client ID (Application ID) of the Azure AD application.
It must be a valid GUID format.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -TenantId
The Tenant ID of the Azure AD directory.
It must be a valid GUID format representing your Microsoft 365 tenant.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -OnMicrosoftUrl
The URL of your onmicrosoft.com domain.
It should be in the format 'example.onmicrosoft.com'.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 4
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -SpAdminUrl
The SharePoint admin URL, which should end with '-admin.sharepoint.com'.
This URL is used for connecting to SharePoint Online.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 5
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -ProgressAction
{{ Fill ProgressAction Description }}
```yaml
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
### None. You cannot pipe objects to this function.
## OUTPUTS
### CISAuthenticationParameters
### The function returns an instance of the CISAuthenticationParameters class containing the authentication details.
## NOTES
Requires PowerShell 7.0 or later.
## RELATED LINKS

View File

@@ -1,4 +1,4 @@
--- ---
external help file: M365FoundationsCISReport-help.xml external help file: M365FoundationsCISReport-help.xml
Module Name: M365FoundationsCISReport Module Name: M365FoundationsCISReport
online version: online version:
@@ -13,7 +13,8 @@ Removes rows from an Excel worksheet where the 'CSV_Status' column is empty and
## SYNTAX ## SYNTAX
``` ```
Remove-RowsWithEmptyCSVStatus [-FilePath] <String> [-WorksheetName] <String> [<CommonParameters>] Remove-RowsWithEmptyCSVStatus [-FilePath] <String> [-WorksheetName] <String>
[-ProgressAction <ActionPreference>] [<CommonParameters>]
``` ```
## DESCRIPTION ## DESCRIPTION
@@ -60,6 +61,21 @@ Accept pipeline input: False
Accept wildcard characters: False Accept wildcard characters: False
``` ```
### -ProgressAction
{{ Fill ProgressAction Description }}
```yaml
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters ### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).

View File

@@ -14,7 +14,7 @@ Synchronizes and updates data in an Excel worksheet with new information from a
``` ```
Sync-CISExcelAndCsvData [[-ExcelPath] <String>] [[-CsvPath] <String>] [[-SheetName] <String>] Sync-CISExcelAndCsvData [[-ExcelPath] <String>] [[-CsvPath] <String>] [[-SheetName] <String>]
[<CommonParameters>] [-ProgressAction <ActionPreference>] [<CommonParameters>]
``` ```
## DESCRIPTION ## DESCRIPTION
@@ -80,6 +80,21 @@ Accept pipeline input: False
Accept wildcard characters: False Accept wildcard characters: False
``` ```
### -ProgressAction
{{ Fill ProgressAction Description }}
```yaml
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters ### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).

View File

@@ -18,9 +18,11 @@ The module includes functionality to synchronize audit results with CIS benchmar
```powershell ```powershell
# Example 1: Performing a security audit based on CIS benchmarks # Example 1: Performing a security audit based on CIS benchmarks
$auditResults = Invoke-M365SecurityAudit -TenantAdminUrl "https://contoso-admin.sharepoint.com" $auditResults = Invoke-M365SecurityAudit -TenantAdminUrl "https://contoso-admin.sharepoint.com"
$auditResults = Invoke-M365SecurityAudit -TenantAdminUrl "https://contoso-admin.sharepoint.com" -DomainName "contoso.com" -ApprovedCloudStorageProviders "DropBox" -ApprovedFederatedDomains "northwind.com"
# Example 2: Exporting a security audit table to a CSV file # Example 2: Exporting a security audit and it's nested tables to zipped CSV files
Export-M365SecurityAuditTable -ExportAllTests -AuditResults $auditResults -ExportPath "C:\temp" -ExportOriginalTests Export-M365SecurityAuditTable -AuditResults $auditResults -ExportPath "C:\temp" -ExportOriginalTests -ExportAllTests
# Output Ex: 2024.07.07_14.55.55_M365FoundationsAudit_368B2E2F.zip
# Example 3: Retrieving licenses for users in administrative roles # Example 3: Retrieving licenses for users in administrative roles
Get-AdminRoleUserLicense Get-AdminRoleUserLicense
@@ -36,6 +38,14 @@ Sync-CISExcelAndCsvData -ExcelPath "path\to\excel.xlsx" -CsvPath "path\to\data.c
# Example 7: Granting Microsoft Graph permissions to the auditor # Example 7: Granting Microsoft Graph permissions to the auditor
Grant-M365SecurityAuditConsent -UserPrincipalNameForConsent 'user@example.com' Grant-M365SecurityAuditConsent -UserPrincipalNameForConsent 'user@example.com'
# Example 8: (PowerShell 7.x Only) Creating a new authentication object for the security audit for app-based authentication.
$authParams = New-M365SecurityAuditAuthObject -ClientCertThumbPrint "ABCDEF1234567890ABCDEF1234567890ABCDEF12" `
-ClientId "12345678-1234-1234-1234-123456789012" `
-TenantId "12345678-1234-1234-1234-123456789012" `
-OnMicrosoftUrl "yourcompany.onmicrosoft.com" `
-SpAdminUrl "https://yourcompany-admin.sharepoint.com"
Invoke-M365SecurityAudit -AuthParams $authParams -TenantAdminUrl "https://yourcompany-admin.sharepoint.com"
``` ```
# NOTE # NOTE

View File

@@ -1,13 +1,14 @@
Import-Module .\output\module\M365FoundationsCISReport\*\*.psd1 Import-Module .\output\module\M365FoundationsCISReport\*\*.psd1
. .\source\Classes\CISAuditResult.ps1
.\helpers\psDoc-master\src\psDoc.ps1 -moduleName M365FoundationsCISReport -outputDir docs -template ".\helpers\psDoc-master\src\out-html-template.ps1" .\helpers\psDoc-master\src\psDoc.ps1 -moduleName M365FoundationsCISReport -outputDir docs -template ".\helpers\psDoc-master\src\out-html-template.ps1"
.\helpers\psDoc-master\src\psDoc.ps1 -moduleName M365FoundationsCISReport -outputDir ".\" -template ".\helpers\psDoc-master\src\out-markdown-template.ps1" -fileName ".\README.md" .\helpers\psDoc-master\src\psDoc.ps1 -moduleName M365FoundationsCISReport -outputDir ".\" -template ".\helpers\psDoc-master\src\out-markdown-template.ps1" -fileName ".\README.md"
<# <#
$ver = "v0.1.18" $ver = "v0.1.28"
git checkout main git checkout main
git pull origin main git pull origin main
git tag -a $ver -m "Release version $ver refactor Update" git tag -a $ver -m "Release version $ver bugfix Update"
git push origin $ver git push origin $ver
"Fix: PR #37" "Fix: PR #37"
git push origin $ver git push origin $ver
@@ -52,13 +53,12 @@ Register-SecretVault -Name ModuleBuildCreds -ModuleName `
"SecretManagement.JustinGrote.CredMan" -ErrorAction Stop "SecretManagement.JustinGrote.CredMan" -ErrorAction Stop
Set-Secret -Name "GalleryApiToken" -Vault ModuleBuildCreds #Set-Secret -Name "GalleryApiToken" -Vault ModuleBuildCreds
Set-Secret -Name "GitHubToken" -Vault ModuleBuildCreds #Set-Secret -Name "GitHubToken" -Vault ModuleBuildCreds
$GalleryApiToken = Get-Secret -Name "GalleryApiToken" -Vault ModuleBuildCreds -AsPlainText $GalleryApiToken = Get-Secret -Name "GalleryApiToken" -Vault ModuleBuildCreds -AsPlainText
$GitHubToken = Get-Secret -Name "GitHubToken" -Vault ModuleBuildCreds -AsPlainText $GitHubToken = Get-Secret -Name "GitHubToken" -Vault ModuleBuildCreds -AsPlainText
$GalleryApiToken $GalleryApiToken
$GitHubToken $GitHubToken

View File

@@ -0,0 +1,43 @@
class CISAuthenticationParameters {
[string]$ClientCertThumbPrint
[string]$ClientId
[string]$TenantId
[string]$OnMicrosoftUrl
[string]$SpAdminUrl
# Constructor with validation
CISAuthenticationParameters(
[string]$ClientCertThumbPrint,
[string]$ClientId,
[string]$TenantId,
[string]$OnMicrosoftUrl,
[string]$SpAdminUrl
) {
# Validate ClientCertThumbPrint
if (-not $ClientCertThumbPrint -or $ClientCertThumbPrint.Length -ne 40 -or $ClientCertThumbPrint -notmatch '^[0-9a-fA-F]{40}$') {
throw [ArgumentException]::new("ClientCertThumbPrint must be a 40-character hexadecimal string.")
}
# Validate ClientId
if (-not $ClientId -or $ClientId -notmatch '^[0-9a-fA-F\-]{36}$') {
throw [ArgumentException]::new("ClientId must be a valid GUID in the format 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'.")
}
# Validate TenantId
if (-not $TenantId -or $TenantId -notmatch '^[0-9a-fA-F\-]{36}$') {
throw [ArgumentException]::new("TenantId must be a valid GUID in the format 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'.")
}
# Validate OnMicrosoftUrl
if (-not $OnMicrosoftUrl -or $OnMicrosoftUrl -notmatch '^[a-zA-Z0-9]+\.onmicrosoft\.com$') {
throw [ArgumentException]::new("OnMicrosoftUrl must be in the format 'example.onmicrosoft.com'.")
}
# Validate SpAdminUrl
if (-not $SpAdminUrl -or $SpAdminUrl -notmatch '^https:\/\/[a-zA-Z0-9\-]+\-admin\.sharepoint\.com$') {
throw [ArgumentException]::new("SpAdminUrl must be in the format 'https://[name]-admin.sharepoint.com'.")
}
# Assign validated properties
$this.ClientCertThumbPrint = $ClientCertThumbPrint
$this.ClientId = $ClientId
$this.TenantId = $TenantId
$this.OnMicrosoftUrl = $OnMicrosoftUrl
$this.SpAdminUrl = $SpAdminUrl
}
}

View File

@@ -33,7 +33,7 @@ Copyright = '(c) 2024 Douglas S. Rios (DrIOSx). All rights reserved.'
Description = 'Automated assessment of 50 CIS 365 Foundations v3.0.0 benchmark.' Description = 'Automated assessment of 50 CIS 365 Foundations v3.0.0 benchmark.'
# Minimum version of the Windows PowerShell engine required by this module # Minimum version of the Windows PowerShell engine required by this module
PowerShellVersion = '5.0' # PowerShellVersion = '5.1'
# Name of the Windows PowerShell host required by this module # Name of the Windows PowerShell host required by this module
# PowerShellHostName = '' # PowerShellHostName = ''
@@ -51,7 +51,7 @@ PowerShellVersion = '5.0'
# ProcessorArchitecture = '' # ProcessorArchitecture = ''
# Modules that must be imported into the global environment prior to importing this module # Modules that must be imported into the global environment prior to importing this module
RequiredModules = @() # RequiredModules = @()
# Assemblies that must be loaded prior to importing this module # Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @() # RequiredAssemblies = @()

View File

@@ -1,37 +1,49 @@
function Assert-ModuleAvailability { function Assert-ModuleAvailability {
[CmdletBinding()]
[OutputType([void]) ] [OutputType([void]) ]
param( param(
[string]$ModuleName, [string]$ModuleName,
[string]$RequiredVersion, [string]$RequiredVersion,
[string[]]$SubModules = @() [string[]]$SubModules = @()
) )
process {
try { try {
$module = Get-Module -ListAvailable -Name $ModuleName | Where-Object { $_.Version -ge [version]$RequiredVersion } $module = Get-Module -ListAvailable -Name $ModuleName | Where-Object { $_.Version -ge [version]$RequiredVersion }
if ($null -eq $module) { if ($null -eq $module) {
Write-Host "Installing $ModuleName module..." -ForegroundColor Yellow Write-Verbose "Installing $ModuleName module..."
Install-Module -Name $ModuleName -RequiredVersion $RequiredVersion -Force -AllowClobber -Scope CurrentUser | Out-Null Install-Module -Name $ModuleName -RequiredVersion $RequiredVersion -Force -AllowClobber -Scope CurrentUser | Out-Null
} }
elseif ($module.Version -lt [version]$RequiredVersion) { elseif ($module.Version -lt [version]$RequiredVersion) {
Write-Host "Updating $ModuleName module to required version..." -ForegroundColor Yellow Write-Verbose "Updating $ModuleName module to required version..."
Update-Module -Name $ModuleName -RequiredVersion $RequiredVersion -Force | Out-Null Update-Module -Name $ModuleName -RequiredVersion $RequiredVersion -Force | Out-Null
} }
else { else {
Write-Host "$ModuleName module is already at required version or newer." -ForegroundColor Gray Write-Verbose "$ModuleName module is already at required version or newer."
}
if ($ModuleName -eq "Microsoft.Graph") {
# "Preloading Microsoft.Graph assembly to prevent type-loading issues..."
Write-Verbose "Preloading Microsoft.Graph assembly to prevent type-loading issues..."
try {
# Run a harmless cmdlet to preload the assembly
Get-MgGroup -Top 1 -ErrorAction SilentlyContinue | Out-Null
}
catch {
Write-Verbose "Could not preload Microsoft.Graph assembly. Error: $_"
}
} }
if ($SubModules.Count -gt 0) { if ($SubModules.Count -gt 0) {
foreach ($subModule in $SubModules) { foreach ($subModule in $SubModules) {
Write-Host "Importing submodule $ModuleName.$subModule..." -ForegroundColor DarkGray Write-Verbose "Importing submodule $ModuleName.$subModule..."
Import-Module -Name "$ModuleName.$subModule" -RequiredVersion $RequiredVersion -ErrorAction Stop | Out-Null Get-Module "$ModuleName.$subModule" | Import-Module -RequiredVersion $RequiredVersion -ErrorAction Stop | Out-Null
} }
} else { }
Write-Host "Importing module $ModuleName..." -ForegroundColor DarkGray else {
Write-Verbose "Importing module $ModuleName..."
Import-Module -Name $ModuleName -RequiredVersion $RequiredVersion -ErrorAction Stop -WarningAction SilentlyContinue | Out-Null Import-Module -Name $ModuleName -RequiredVersion $RequiredVersion -ErrorAction Stop -WarningAction SilentlyContinue | Out-Null
} }
} }
catch { catch {
Write-Warning "An error occurred with module $ModuleName`: $_" throw "Assert-ModuleAvailability:`n$_"
}
} }
} }

View File

@@ -5,6 +5,9 @@ function Connect-M365Suite {
[Parameter(Mandatory = $false)] [Parameter(Mandatory = $false)]
[string]$TenantAdminUrl, [string]$TenantAdminUrl,
[Parameter(Mandatory = $false)]
[CISAuthenticationParameters]$AuthParams,
[Parameter(Mandatory)] [Parameter(Mandatory)]
[string[]]$RequiredConnections, [string[]]$RequiredConnections,
@@ -12,111 +15,131 @@ function Connect-M365Suite {
[switch]$SkipConfirmation [switch]$SkipConfirmation
) )
$VerbosePreference = "SilentlyContinue" $VerbosePreference = if ($SkipConfirmation) { 'SilentlyContinue' } else { 'Continue' }
$tenantInfo = @() $tenantInfo = @()
$connectedServices = @() $connectedServices = @()
try { try {
if ($RequiredConnections -contains "AzureAD" -or $RequiredConnections -contains "AzureAD | EXO" -or $RequiredConnections -contains "AzureAD | EXO | Microsoft Graph") { if ($RequiredConnections -contains 'Microsoft Graph' -or $RequiredConnections -contains 'EXO | Microsoft Graph') {
Write-Host "Connecting to Azure Active Directory..." -ForegroundColor Yellow
Connect-AzureAD -WarningAction SilentlyContinue | Out-Null
$tenantDetails = Get-AzureADTenantDetail -WarningAction SilentlyContinue
$tenantInfo += [PSCustomObject]@{
Service = "Azure Active Directory"
TenantName = $tenantDetails.DisplayName
TenantID = $tenantDetails.ObjectId
}
$connectedServices += "AzureAD"
Write-Host "Successfully connected to Azure Active Directory." -ForegroundColor Green
}
if ($RequiredConnections -contains "Microsoft Graph" -or $RequiredConnections -contains "EXO | Microsoft Graph") {
Write-Host "Connecting to Microsoft Graph with scopes: Directory.Read.All, Domain.Read.All, Policy.Read.All, Organization.Read.All" -ForegroundColor Yellow
try { try {
Connect-MgGraph -Scopes "Directory.Read.All", "Domain.Read.All", "Policy.Read.All", "Organization.Read.All" -NoWelcome | Out-Null Write-Verbose 'Connecting to Microsoft Graph...'
if ($AuthParams) {
Connect-MgGraph -CertificateThumbprint $AuthParams.ClientCertThumbPrint -AppId $AuthParams.ClientId -TenantId $AuthParams.TenantId -NoWelcome | Out-Null
}
else {
Connect-MgGraph -Scopes 'Directory.Read.All', 'Domain.Read.All', 'Policy.Read.All', 'Organization.Read.All' -NoWelcome | Out-Null
}
$graphOrgDetails = Get-MgOrganization $graphOrgDetails = Get-MgOrganization
$tenantInfo += [PSCustomObject]@{ $tenantInfo += [PSCustomObject]@{
Service = "Microsoft Graph" Service = 'Microsoft Graph'
TenantName = $graphOrgDetails.DisplayName TenantName = $graphOrgDetails.DisplayName
TenantID = $graphOrgDetails.Id TenantID = $graphOrgDetails.Id
} }
$connectedServices += "Microsoft Graph" $connectedServices += 'Microsoft Graph'
Write-Host "Successfully connected to Microsoft Graph with specified scopes." -ForegroundColor Green Write-Verbose 'Successfully connected to Microsoft Graph.'
} }
catch { catch {
Write-Host "Failed to connect to MgGraph, attempting device auth." -ForegroundColor Yellow throw "Failed to connect to Microsoft Graph: $($_.Exception.Message)"
Connect-MgGraph -Scopes "Directory.Read.All", "Domain.Read.All", "Policy.Read.All", "Organization.Read.All" -UseDeviceCode -NoWelcome | Out-Null
$graphOrgDetails = Get-MgOrganization
$tenantInfo += [PSCustomObject]@{
Service = "Microsoft Graph"
TenantName = $graphOrgDetails.DisplayName
TenantID = $graphOrgDetails.Id
}
$connectedServices += "Microsoft Graph"
Write-Host "Successfully connected to Microsoft Graph with specified scopes." -ForegroundColor Green
} }
} }
if ($RequiredConnections -contains "EXO" -or $RequiredConnections -contains "AzureAD | EXO" -or $RequiredConnections -contains "Microsoft Teams | EXO" -or $RequiredConnections -contains "EXO | Microsoft Graph") { if ($RequiredConnections -contains 'EXO' -or $RequiredConnections -contains 'AzureAD | EXO' -or $RequiredConnections -contains 'Microsoft Teams | EXO' -or $RequiredConnections -contains 'EXO | Microsoft Graph') {
Write-Host "Connecting to Exchange Online..." -ForegroundColor Yellow try {
Write-Verbose 'Connecting to Exchange Online...'
if ($AuthParams) {
Connect-ExchangeOnline -AppId $AuthParams.ClientId -CertificateThumbprint $AuthParams.ClientCertThumbPrint -Organization $AuthParams.OnMicrosoftUrl -ShowBanner:$false | Out-Null
}
else {
Connect-ExchangeOnline -ShowBanner:$false | Out-Null Connect-ExchangeOnline -ShowBanner:$false | Out-Null
}
$exoTenant = (Get-OrganizationConfig).Identity $exoTenant = (Get-OrganizationConfig).Identity
$tenantInfo += [PSCustomObject]@{ $tenantInfo += [PSCustomObject]@{
Service = "Exchange Online" Service = 'Exchange Online'
TenantName = $exoTenant TenantName = $exoTenant
TenantID = "N/A" TenantID = 'N/A'
}
$connectedServices += 'EXO'
Write-Verbose 'Successfully connected to Exchange Online.'
}
catch {
throw "Failed to connect to Exchange Online: $($_.Exception.Message)"
} }
$connectedServices += "EXO"
Write-Host "Successfully connected to Exchange Online." -ForegroundColor Green
} }
if ($RequiredConnections -contains "SPO") { if ($RequiredConnections -contains 'SPO') {
Write-Host "Connecting to SharePoint Online..." -ForegroundColor Yellow try {
Write-Verbose 'Connecting to SharePoint Online...'
if ($AuthParams) {
Connect-PnPOnline -Url $AuthParams.SpAdminUrl -ClientId $AuthParams.ClientId -Tenant $AuthParams.OnMicrosoftUrl -Thumbprint $AuthParams.ClientCertThumbPrint | Out-Null
}
else {
Connect-SPOService -Url $TenantAdminUrl | Out-Null Connect-SPOService -Url $TenantAdminUrl | Out-Null
$spoContext = Get-SPOCrossTenantHostUrl }
$tenantName = Get-UrlLine -Output $spoContext $tenantName = if ($AuthParams) {
(Get-PnPSite).Url
}
else {
# Supress output from Get-SPOSite for powerautomate to avoid errors
[void]($sites = Get-SPOSite -Limit All)
# Get the URL from the first site collection
$url = $sites[0].Url
# Use regex to extract the base URL up to the .com portion
$baseUrl = [regex]::Match($url, 'https://[^/]+.com').Value
# Output the base URL
$baseUrl
}
$tenantInfo += [PSCustomObject]@{ $tenantInfo += [PSCustomObject]@{
Service = "SharePoint Online" Service = 'SharePoint Online'
TenantName = $tenantName TenantName = $tenantName
} }
$connectedServices += "SPO" $connectedServices += 'SPO'
Write-Host "Successfully connected to SharePoint Online." -ForegroundColor Green Write-Verbose 'Successfully connected to SharePoint Online.'
}
catch {
throw "Failed to connect to SharePoint Online: $($_.Exception.Message)"
}
} }
if ($RequiredConnections -contains "Microsoft Teams" -or $RequiredConnections -contains "Microsoft Teams | EXO") { if ($RequiredConnections -contains 'Microsoft Teams' -or $RequiredConnections -contains 'Microsoft Teams | EXO') {
Write-Host "Connecting to Microsoft Teams..." -ForegroundColor Yellow try {
Write-Verbose 'Connecting to Microsoft Teams...'
if ($AuthParams) {
Connect-MicrosoftTeams -TenantId $AuthParams.TenantId -CertificateThumbprint $AuthParams.ClientCertThumbPrint -ApplicationId $AuthParams.ClientId | Out-Null
}
else {
Connect-MicrosoftTeams | Out-Null Connect-MicrosoftTeams | Out-Null
}
$teamsTenantDetails = Get-CsTenant $teamsTenantDetails = Get-CsTenant
$tenantInfo += [PSCustomObject]@{ $tenantInfo += [PSCustomObject]@{
Service = "Microsoft Teams" Service = 'Microsoft Teams'
TenantName = $teamsTenantDetails.DisplayName TenantName = $teamsTenantDetails.DisplayName
TenantID = $teamsTenantDetails.TenantId TenantID = $teamsTenantDetails.TenantId
} }
$connectedServices += "Microsoft Teams" $connectedServices += 'Microsoft Teams'
Write-Host "Successfully connected to Microsoft Teams." -ForegroundColor Green Write-Verbose 'Successfully connected to Microsoft Teams.'
}
catch {
throw "Failed to connect to Microsoft Teams: $($_.Exception.Message)"
}
} }
# Display tenant information and confirm with the user
if (-not $SkipConfirmation) { if (-not $SkipConfirmation) {
Write-Host "Connected to the following tenants:" -ForegroundColor Yellow Write-Verbose 'Connected to the following tenants:'
foreach ($tenant in $tenantInfo) { foreach ($tenant in $tenantInfo) {
Write-Host "Service: $($tenant.Service)" -ForegroundColor Cyan Write-Verbose "Service: $($tenant.Service) | Tenant: $($tenant.TenantName)"
Write-Host "Tenant Context: $($tenant.TenantName)`n" -ForegroundColor Green
#Write-Host "Tenant ID: $($tenant.TenantID)"
} }
$confirmation = Read-Host "Do you want to proceed with these connections? (Y/N)" $confirmation = Read-Host 'Do you want to proceed with these connections? (Y/N)'
if ($confirmation -notlike 'Y') { if ($confirmation -notlike 'Y') {
Write-Host "Connection setup aborted by user." -ForegroundColor Red
Disconnect-M365Suite -RequiredConnections $connectedServices Disconnect-M365Suite -RequiredConnections $connectedServices
throw "User aborted connection setup." throw 'User aborted connection setup.'
} }
} }
} }
catch { catch {
$VerbosePreference = "Continue" $VerbosePreference = 'Continue'
Write-Host "There was an error establishing one or more connections: $_" -ForegroundColor Red throw "Connection failed: $($_.Exception.Message)"
throw $_ }
finally {
$VerbosePreference = 'Continue'
} }
$VerbosePreference = "Continue"
} }

View File

@@ -8,7 +8,7 @@ function Disconnect-M365Suite {
# Clean up sessions # Clean up sessions
try { try {
if ($RequiredConnections -contains "EXO" -or $RequiredConnections -contains "AzureAD | EXO" -or $RequiredConnections -contains "Microsoft Teams | EXO") { if ($RequiredConnections -contains "EXO" -or $RequiredConnections -contains "AzureAD | EXO" -or $RequiredConnections -contains "Microsoft Teams | EXO") {
Write-Host "Disconnecting from Exchange Online..." -ForegroundColor Green Write-Verbose "Disconnecting from Exchange Online..."
Disconnect-ExchangeOnline -Confirm:$false | Out-Null Disconnect-ExchangeOnline -Confirm:$false | Out-Null
} }
} }
@@ -18,7 +18,7 @@ function Disconnect-M365Suite {
try { try {
if ($RequiredConnections -contains "AzureAD" -or $RequiredConnections -contains "AzureAD | EXO") { if ($RequiredConnections -contains "AzureAD" -or $RequiredConnections -contains "AzureAD | EXO") {
Write-Host "Disconnecting from Azure AD..." -ForegroundColor Green Write-Verbose "Disconnecting from Azure AD..."
Disconnect-AzureAD | Out-Null Disconnect-AzureAD | Out-Null
} }
} }
@@ -28,7 +28,7 @@ function Disconnect-M365Suite {
try { try {
if ($RequiredConnections -contains "Microsoft Graph") { if ($RequiredConnections -contains "Microsoft Graph") {
Write-Host "Disconnecting from Microsoft Graph..." -ForegroundColor Green Write-Verbose "Disconnecting from Microsoft Graph..."
Disconnect-MgGraph | Out-Null Disconnect-MgGraph | Out-Null
} }
} }
@@ -38,23 +38,28 @@ function Disconnect-M365Suite {
try { try {
if ($RequiredConnections -contains "SPO") { if ($RequiredConnections -contains "SPO") {
Write-Host "Disconnecting from SharePoint Online..." -ForegroundColor Green if (($script:PnpAuth)) {
Write-Verbose "Disconnecting from PnPOnline..."
Disconnect-PnPOnline | Out-Null
}
else {
Write-Verbose "Disconnecting from SharePoint Online..."
Disconnect-SPOService | Out-Null Disconnect-SPOService | Out-Null
} }
} }
}
catch { catch {
Write-Warning "Failed to disconnect from SharePoint Online: $_" Write-Warning "Failed to disconnect from SharePoint Online: $_"
} }
try { try {
if ($RequiredConnections -contains "Microsoft Teams" -or $RequiredConnections -contains "Microsoft Teams | EXO") { if ($RequiredConnections -contains "Microsoft Teams" -or $RequiredConnections -contains "Microsoft Teams | EXO") {
Write-Host "Disconnecting from Microsoft Teams..." -ForegroundColor Green Write-Verbose "Disconnecting from Microsoft Teams..."
Disconnect-MicrosoftTeams | Out-Null Disconnect-MicrosoftTeams | Out-Null
} }
} }
catch { catch {
Write-Warning "Failed to disconnect from Microsoft Teams: $_" Write-Warning "Failed to disconnect from Microsoft Teams: $_"
} }
Write-Verbose "All necessary sessions have been disconnected."
Write-Host "All necessary sessions have been disconnected." -ForegroundColor Green
} }

View File

@@ -11,6 +11,12 @@ function Get-Action {
[ValidateSet("Admin", "Delegate", "Owner")] [ValidateSet("Admin", "Delegate", "Owner")]
[string]$ActionType, [string]$ActionType,
[Parameter(Position = 2, Mandatory = $true, ParameterSetName = "ConvertActions")]
[Parameter(Position = 2, Mandatory = $true, ParameterSetName = "ReverseActions")]
[Parameter(Position = 1, Mandatory = $true, ParameterSetName = "GetDictionaries")]
[ValidateSet("6.1.2", "6.1.3")]
[string]$Version = "6.1.2",
[Parameter(Position = 0, ParameterSetName = "ReverseActions")] [Parameter(Position = 0, ParameterSetName = "ReverseActions")]
[string[]]$AbbreviatedActions, [string[]]$AbbreviatedActions,
@@ -20,6 +26,52 @@ function Get-Action {
) )
$Dictionary = @{ $Dictionary = @{
"6.1.2" = @{
AdminActions = @{
ApplyRecord = 'AR'
Copy = 'CP'
Create = 'CR'
FolderBind = 'FB'
HardDelete = 'HD'
Move = 'MV'
MoveToDeletedItems = 'MTDI'
SendAs = 'SA'
SendOnBehalf = 'SOB'
SoftDelete = 'SD'
Update = 'UP'
UpdateCalendarDelegation = 'UCD'
UpdateFolderPermissions = 'UFP'
UpdateInboxRules = 'UIR'
}
DelegateActions = @{
ApplyRecord = 'AR'
Create = 'CR'
FolderBind = 'FB'
HardDelete = 'HD'
Move = 'MV'
MoveToDeletedItems = 'MTDI'
SendAs = 'SA'
SendOnBehalf = 'SOB'
SoftDelete = 'SD'
Update = 'UP'
UpdateFolderPermissions = 'UFP'
UpdateInboxRules = 'UIR'
}
OwnerActions = @{
ApplyRecord = 'AR'
Create = 'CR'
HardDelete = 'HD'
MailboxLogin = 'ML'
Move = 'MV'
MoveToDeletedItems = 'MTDI'
SoftDelete = 'SD'
Update = 'UP'
UpdateCalendarDelegation = 'UCD'
UpdateFolderPermissions = 'UFP'
UpdateInboxRules = 'UIR'
}
}
"6.1.3" = @{
AdminActions = @{ AdminActions = @{
ApplyRecord = 'AR' ApplyRecord = 'AR'
Copy = 'CP' Copy = 'CP'
@@ -69,12 +121,15 @@ function Get-Action {
UpdateInboxRules = 'UIR' UpdateInboxRules = 'UIR'
} }
} }
}
switch ($PSCmdlet.ParameterSetName) { switch ($PSCmdlet.ParameterSetName) {
"GetDictionaries" { "GetDictionaries" {
return $Dictionary return $Dictionary[$Version]
} }
"ConvertActions" { "ConvertActions" {
try {
$Dictionary = $Dictionary[$Version]
$actionDictionary = switch ($ActionType) { $actionDictionary = switch ($ActionType) {
"Admin" { $Dictionary.AdminActions } "Admin" { $Dictionary.AdminActions }
"Delegate" { $Dictionary.DelegateActions } "Delegate" { $Dictionary.DelegateActions }
@@ -89,18 +144,23 @@ function Get-Action {
} }
return $abbreviatedActions return $abbreviatedActions
} }
catch {
throw $_
}
}
"ReverseActions" { "ReverseActions" {
try {
$Dictionary = $Dictionary[$Version]
$reverseDictionary = @{} $reverseDictionary = @{}
$originalDictionary = switch ($ReverseActionType) { $originalDictionary = switch ($ReverseActionType) {
"Admin" { $Dictionary.AdminActions } "Admin" { $Dictionary.AdminActions }
"Delegate" { $Dictionary.DelegateActions } "Delegate" { $Dictionary.DelegateActions }
"Owner" { $Dictionary.OwnerActions } "Owner" { $Dictionary.OwnerActions }
} }
foreach ($key in $originalDictionary.Keys) { foreach ($key in $originalDictionary.Keys) {
$reverseDictionary[$originalDictionary[$key]] = $key $reverseDictionary[$originalDictionary[$key]] = $key
} }
$fullNames = @() $fullNames = @()
foreach ($abbrAction in $AbbreviatedActions) { foreach ($abbrAction in $AbbreviatedActions) {
if ($reverseDictionary.ContainsKey($abbrAction)) { if ($reverseDictionary.ContainsKey($abbrAction)) {
@@ -109,5 +169,9 @@ function Get-Action {
} }
return $fullNames return $fullNames
} }
catch {
throw $_
}
}
} }
} }

View File

@@ -0,0 +1,33 @@
function Get-AuditMailboxDetail {
[cmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[String]$Details,
[Parameter(Mandatory = $true)]
[String]$Version
)
process {
switch ($Version) {
"6.1.2" { [string]$VersionText = "No M365 E3 licenses found."}
"6.1.3" { [string]$VersionText = "No M365 E5 licenses found."}
}
if ($details -ne $VersionText ) {
$csv = $details | ConvertFrom-Csv -Delimiter '|'
}
else {
$csv = $null
}
if ($null -ne $csv) {
foreach ($row in $csv) {
$row.AdminActionsMissing = (Get-Action -AbbreviatedActions $row.AdminActionsMissing.Split(',') -ReverseActionType Admin -Version $Version) -join ','
$row.DelegateActionsMissing = (Get-Action -AbbreviatedActions $row.DelegateActionsMissing.Split(',') -ReverseActionType Delegate -Version $Version ) -join ','
$row.OwnerActionsMissing = (Get-Action -AbbreviatedActions $row.OwnerActionsMissing.Split(',') -ReverseActionType Owner -Version $Version ) -join ','
}
$newObjectDetails = $csv
}
else {
$newObjectDetails = $details
}
return $newObjectDetails
}
}

View File

@@ -46,6 +46,7 @@ function Get-CISExoOutput {
#> #>
} }
process { process {
try {
Write-Verbose "Get-CISExoOutput: Retuning data for Rec: $Rec" Write-Verbose "Get-CISExoOutput: Retuning data for Rec: $Rec"
switch ($Rec) { switch ($Rec) {
'1.2.2' { '1.2.2' {
@@ -87,60 +88,6 @@ function Get-CISExoOutput {
# [psobject[]] # [psobject[]]
return $sharingPolicies return $sharingPolicies
} }
'1.3.3b' {
# $mailboxes Mock Object
<#
$mailboxes = @(
[PSCustomObject]@{
UserPrincipalName = "SMBuser1@domain.com"
ExternalDirectoryObjectId = "123e4567-e89b-12d3-a456-426614174000"
PrimarySmtpAddress = "SMBuser1@domain.com"
PublishEnabled = $False
PublishedCalendarUrl = "https://example.com/calendar/smbuser1"
},
[PSCustomObject]@{
UserPrincipalName = "SMBuser2@domain.com"
ExternalDirectoryObjectId = "987e6543-21ba-12d3-a456-426614174000"
PrimarySmtpAddress = "SMBuser2@domain.com"
PublishEnabled = $False
PublishedCalendarUrl = "https://example.com/calendar/smbuser2"
},
[PSCustomObject]@{
UserPrincipalName = "SMBuser3@domain.com"
ExternalDirectoryObjectId = "abcddcba-98fe-76dc-a456-426614174000"
PrimarySmtpAddress = "SMBuser3@domain.com"
PublishEnabled = $False
PublishedCalendarUrl = "https://example.com/calendar/smbuser3"
}
)
#>
$mailboxes = Get-Mailbox -ResultSize Unlimited
$results = foreach ($mailbox in $mailboxes) {
# Get the name of the default calendar folder (depends on the mailbox's language)
# Return single string Ex: return "Calendar" x 3 in array
$calendarFolder = [string](Get-EXOMailboxFolderStatistics $mailbox.PrimarySmtpAddress -Folderscope Calendar | Where-Object { $_.FolderType -eq 'Calendar' }).Name
Write-Verbose "Calendar folder for $($mailbox.PrimarySmtpAddress): $calendarFolder"
# Get users calendar folder settings for their default Calendar folder
# calendar has the format identity:\<calendar folder name>
$calendar = Get-MailboxCalendarFolder -Identity "$($mailbox.PrimarySmtpAddress):\$calendarFolder"
#Write-Host "Calendar object for $($mailbox.PrimarySmtpAddress): $calendar"
Write-Verbose "Calendar publishing enabled: $($calendar.PublishEnabled)"
# Check if calendar publishing is enabled and create a custom object
if ($calendar.PublishEnabled) {
[PSCustomObject]@{
PrimarySmtpAddress = $mailbox.PrimarySmtpAddress
CalendarFolder = $calendarFolder
PublishEnabled = $calendar.PublishEnabled
PublishedCalendarUrl = $calendar.PublishedCalendarUrl
}
}
}
$calendarDetails = @()
foreach ($calendar in $results) {
$calendarDetails += "Calendar: $($calendar.PrimarySmtpAddress); URL: $($calendar.PublishedCalendarUrl)"
}
return $calendarDetails
}
'1.3.6' { '1.3.6' {
# Test-CustomerLockbox.ps1 # Test-CustomerLockbox.ps1
# Step: Retrieve the organization configuration (Condition C: Pass/Fail) # Step: Retrieve the organization configuration (Condition C: Pass/Fail)
@@ -274,10 +221,11 @@ function Get-CISExoOutput {
) )
#> #>
$safeAttachmentPolicies = Get-SafeAttachmentPolicy -ErrorAction SilentlyContinue | Where-Object { $_.Enable -eq $true } $safeAttachmentPolicies = Get-SafeAttachmentPolicy -ErrorAction SilentlyContinue | Where-Object { $_.Enable -eq $true }
$safeAttachmentRules = Get-SafeAttachmentRule
# [object[]] # [object[]]
return $safeAttachmentPolicies return $safeAttachmentPolicies, $safeAttachmentRules
else { else {
return 1 return 1,1
} }
} }
} }
@@ -532,6 +480,10 @@ function Get-CISExoOutput {
default { throw "No match found for test: $Rec" } default { throw "No match found for test: $Rec" }
} }
} }
catch {
throw "Get-CISExoOutput: `n$_"
}
}
end { end {
Write-Verbose "Retuning data for Rec: $Rec" Write-Verbose "Retuning data for Rec: $Rec"
} }

View File

@@ -34,6 +34,7 @@ function Get-CISMSTeamsOutput {
#> #>
} }
process { process {
try {
Write-Verbose "Get-CISMSTeamsOutput: Retuning data for Rec: $Rec" Write-Verbose "Get-CISMSTeamsOutput: Retuning data for Rec: $Rec"
switch ($Rec) { switch ($Rec) {
'8.1.1' { '8.1.1' {
@@ -326,6 +327,10 @@ function Get-CISMSTeamsOutput {
default { throw "No match found for test: $Rec" } default { throw "No match found for test: $Rec" }
} }
} }
catch {
throw "Get-CISMSTeamsOutput: `n$_"
}
}
end { end {
Write-Verbose "Retuning data for Rec: $Rec" Write-Verbose "Retuning data for Rec: $Rec"
} }

View File

@@ -38,14 +38,17 @@ function Get-CISMgOutput {
#> #>
} }
process { process {
try {
Write-Verbose "Get-CISMgOutput: Retuning data for Rec: $Rec" Write-Verbose "Get-CISMgOutput: Retuning data for Rec: $Rec"
switch ($rec) { switch ($rec) {
'1.1.1' { '1.1.1' {
# 1.1.1 # 1.1.1
# Test-AdministrativeAccountCompliance
$AdminRoleAssignmentsAndUsers = Get-AdminRoleUserAndAssignment $AdminRoleAssignmentsAndUsers = Get-AdminRoleUserAndAssignment
return $AdminRoleAssignmentsAndUsers return $AdminRoleAssignmentsAndUsers
} }
'1.1.3' { '1.1.3' {
# Test-GlobalAdminsCount
# Step: Retrieve global admin role # Step: Retrieve global admin role
$globalAdminRole = Get-MgDirectoryRole -Filter "RoleTemplateId eq '62e90394-69f5-4237-9190-012177145e10'" $globalAdminRole = Get-MgDirectoryRole -Filter "RoleTemplateId eq '62e90394-69f5-4237-9190-012177145e10'"
# Step: Retrieve global admin members # Step: Retrieve global admin members
@@ -53,9 +56,15 @@ function Get-CISMgOutput {
return $globalAdmins return $globalAdmins
} }
'1.2.1' { '1.2.1' {
# Test-ManagedApprovedPublicGroups
$allGroups = Get-MgGroup -All | Where-Object { $_.Visibility -eq "Public" } | Select-Object DisplayName, Visibility $allGroups = Get-MgGroup -All | Where-Object { $_.Visibility -eq "Public" } | Select-Object DisplayName, Visibility
return $allGroups return $allGroups
} }
'1.2.2' {
# Test-BlockSharedMailboxSignIn.ps1
$users = Get-MgUser
return $users
}
'1.3.1' { '1.3.1' {
# Test-PasswordNeverExpirePolicy.ps1 # Test-PasswordNeverExpirePolicy.ps1
$domains = if ($DomainName) { $domains = if ($DomainName) {
@@ -67,21 +76,24 @@ function Get-CISMgOutput {
return $domains return $domains
} }
'5.1.2.3' { '5.1.2.3' {
# Test-RestrictTenantCreation
# Retrieve the tenant creation policy # Retrieve the tenant creation policy
$tenantCreationPolicy = (Get-MgPolicyAuthorizationPolicy).DefaultUserRolePermissions | Select-Object AllowedToCreateTenants $tenantCreationPolicy = (Get-MgPolicyAuthorizationPolicy).DefaultUserRolePermissions | Select-Object AllowedToCreateTenants
return $tenantCreationPolicy return $tenantCreationPolicy
} }
'5.1.8.1' { '5.1.8.1' {
# Test-PasswordHashSync
# Retrieve password hash sync status (Condition A and C) # Retrieve password hash sync status (Condition A and C)
$passwordHashSync = Get-MgOrganization | Select-Object -ExpandProperty OnPremisesSyncEnabled $passwordHashSync = Get-MgOrganization | Select-Object -ExpandProperty OnPremisesSyncEnabled
return $passwordHashSync return $passwordHashSync
} }
'6.1.2' { '6.1.2' {
$tenantSkus = Get-MgSubscribedSku -All # Test-MailboxAuditingE3
$tenantSKUs = Get-MgSubscribedSku -All
$e3SkuPartNumber = "SPE_E3" $e3SkuPartNumber = "SPE_E3"
$founde3Sku = $tenantSkus | Where-Object { $_.SkuPartNumber -eq $e3SkuPartNumber } $foundE3Sku = $tenantSKUs | Where-Object { $_.SkuPartNumber -eq $e3SkuPartNumber }
if ($founde3Sku.Count -ne 0) { if ($foundE3Sku.Count -ne 0) {
$allE3Users = Get-MgUser -Filter "assignedLicenses/any(x:x/skuId eq $($founde3Sku.SkuId) )" -All $allE3Users = Get-MgUser -Filter "assignedLicenses/any(x:x/skuId eq $($foundE3Sku.SkuId) )" -All
return $allE3Users return $allE3Users
} }
else { else {
@@ -89,11 +101,12 @@ function Get-CISMgOutput {
} }
} }
'6.1.3' { '6.1.3' {
$tenantSkus = Get-MgSubscribedSku -All # Test-MailboxAuditingE5
$tenantSKUs = Get-MgSubscribedSku -All
$e5SkuPartNumber = "SPE_E5" $e5SkuPartNumber = "SPE_E5"
$founde5Sku = $tenantSkus | Where-Object { $_.SkuPartNumber -eq $e5SkuPartNumber } $foundE5Sku = $tenantSKUs | Where-Object { $_.SkuPartNumber -eq $e5SkuPartNumber }
if ($founde5Sku.Count -ne 0) { if ($foundE5Sku.Count -ne 0) {
$allE5Users = Get-MgUser -Filter "assignedLicenses/any(x:x/skuId eq $($founde5Sku.SkuId) )" -All $allE5Users = Get-MgUser -Filter "assignedLicenses/any(x:x/skuId eq $($foundE5Sku.SkuId) )" -All
return $allE5Users return $allE5Users
} }
else { else {
@@ -103,6 +116,10 @@ function Get-CISMgOutput {
default { throw "No match found for test: $Rec" } default { throw "No match found for test: $Rec" }
} }
} }
catch {
throw "Get-CISMgOutput: `n$_"
}
}
end { end {
Write-Verbose "Retuning data for Rec: $Rec" Write-Verbose "Retuning data for Rec: $Rec"
} }

View File

@@ -1,119 +1,161 @@
<# <#
.SYNOPSIS .SYNOPSIS
This is a sample Private function only visible within the module. Retrieves configuration settings from SharePoint Online or PnP based on the specified recommendation.
.DESCRIPTION .DESCRIPTION
This sample function is not exported to the module and only return the data passed as parameter. The Get-CISSpoOutput function retrieves specific configuration settings from SharePoint Online or PnP based on a recommendation number.
It dynamically switches between using SPO and PnP commands based on the provided authentication context.
.PARAMETER Rec
The recommendation number corresponding to the specific test to be run.
.INPUTS
None. You cannot pipe objects to this function.
.OUTPUTS
PSCustomObject
Returns configuration details for the specified recommendation.
.EXAMPLE .EXAMPLE
$null = Get-CISSpoOutput -PrivateData 'NOTHING TO SEE HERE' PS> Get-CISSpoOutput -Rec '7.2.1'
.PARAMETER PrivateData Retrieves the LegacyAuthProtocolsEnabled property from the SharePoint Online or PnP tenant.
The PrivateData parameter is what will be returned without transformation.
#> #>
function Get-CISSpoOutput { function Get-CISSpoOutput {
[cmdletBinding()] [CmdletBinding()]
param( param(
[Parameter(Mandatory = $true)] [Parameter(Mandatory = $true, HelpMessage = "The recommendation number corresponding to the specific test to be run.")]
[String]$Rec [String]$Rec
) )
begin { begin {
# Begin Block # # Check if PnP should be used
<# $UsePnP = $script:PnpAuth
# Tests # Determine the prefix based on the switch
7.2.1 $prefix = if ($UsePnP) { "PnP" } else { "SPO" }
7.2.2 # Define a hashtable to map the function calls
7.2.3 $commandMap = @{
7.2.4
7.2.5
7.2.6
7.2.7
7.2.9
7.2.10
7.3.1
7.3.2
7.3.4
# Test number array
$testNumbers = @('7.2.1', '7.2.2', '7.2.3', '7.2.4', '7.2.5', '7.2.6', '7.2.7', '7.2.9', '7.2.10', '7.3.1', '7.3.2', '7.3.4')
#>
}
process {
Write-Verbose "Retuning data for Rec: $Rec"
switch ($Rec) {
'7.2.1' {
# Test-ModernAuthSharePoint.ps1 # Test-ModernAuthSharePoint.ps1
$SPOTenant = Get-SPOTenant | Select-Object -Property LegacyAuthProtocolsEnabled # 7.2.1 (L1) Ensure Legacy Authentication Protocols are disabled
return $SPOTenant # $SPOTenant Mock Object
'7.2.1' = {
Invoke-Command {
& "$((Get-Command -Name "Get-${prefix}Tenant").Name)"
} | Select-Object -Property LegacyAuthProtocolsEnabled
} }
'7.2.2' {
# Test-SharePointAADB2B.ps1 # Test-SharePointAADB2B.ps1
# 7.2.2 (L1) Ensure SharePoint and OneDrive integration with Azure AD B2B is enabled # 7.2.2 (L1) Ensure SharePoint and OneDrive integration with Azure AD B2B is enabled
$SPOTenantAzureADB2B = Get-SPOTenant | Select-Object EnableAzureADB2BIntegration # $SPOTenantAzureADB2B Mock Object
return $SPOTenantAzureADB2B '7.2.2' = {
Invoke-Command {
& "$((Get-Command -Name "Get-${prefix}Tenant").Name)"
} | Select-Object -Property EnableAzureADB2BIntegration
} }
'7.2.3' {
# Test-RestrictExternalSharing.ps1 # Test-RestrictExternalSharing.ps1
# 7.2.3 (L1) Ensure external content sharing is restricted # 7.2.3 (L1) Ensure external content sharing is restricted
# Retrieve the SharingCapability setting for the SharePoint tenant # Retrieve the SharingCapability setting for the SharePoint tenant
$SPOTenantSharingCapability = Get-SPOTenant | Select-Object SharingCapability # $SPOTenantSharingCapability Mock Object
return $SPOTenantSharingCapability '7.2.3' = {
Invoke-Command {
& "$((Get-Command -Name "Get-${prefix}Tenant").Name)"
} | Select-Object -Property SharingCapability
} }
'7.2.4' {
# Test-OneDriveContentRestrictions.ps1 # Test-OneDriveContentRestrictions.ps1
$SPOTenant = Get-SPOTenant | Select-Object OneDriveSharingCapability # 7.2.4 (L2) Ensure OneDrive content sharing is restricted
return $SPOTenant # $SPOTenant Mock Object
'7.2.4' = {
Invoke-Command {
if ($prefix -eq "SPO") {
& "$((Get-Command -Name "Get-${prefix}Tenant").Name)" | Select-Object -Property OneDriveSharingCapability
} else {
# Workaround until bugfix in PnP.PowerShell
& "$((Get-Command -Name "Get-${prefix}Tenant").Name)" | Select-Object -Property OneDriveLoopSharingCapability | Select-Object @{Name = "OneDriveSharingCapability"; Expression = { $_.OneDriveLoopSharingCapability }}
}
}
} }
'7.2.5' {
# Test-SharePointGuestsItemSharing.ps1 # Test-SharePointGuestsItemSharing.ps1
# 7.2.5 (L2) Ensure that SharePoint guest users cannot share items they don't own # 7.2.5 (L2) Ensure that SharePoint guest users cannot share items they don't own
$SPOTenant = Get-SPOTenant | Select-Object PreventExternalUsersFromResharing # $SPOTenant Mock Object
return $SPOTenant '7.2.5' = {
Invoke-Command {
& "$((Get-Command -Name "Get-${prefix}Tenant").Name)"
} | Select-Object -Property PreventExternalUsersFromResharing
} }
'7.2.6' {
# Test-SharePointExternalSharingDomains.ps1 # Test-SharePointExternalSharingDomains.ps1
# 7.2.6 (L2) Ensure SharePoint external sharing is managed through domain whitelist/blacklists # 7.2.6 (L2) Ensure SharePoint external sharing is managed through domain whitelist/blacklists
$SPOTenant = Get-SPOTenant | Select-Object SharingDomainRestrictionMode, SharingAllowedDomainList # Add Authorized Domains?
return $SPOTenant # $SPOTenant Mock Object
'7.2.6' = {
Invoke-Command {
& "$((Get-Command -Name "Get-${prefix}Tenant").Name)"
} | Select-Object -Property SharingDomainRestrictionMode, SharingAllowedDomainList
} }
'7.2.7' {
# Test-LinkSharingRestrictions.ps1 # Test-LinkSharingRestrictions.ps1
# Retrieve link sharing configuration for SharePoint and OneDrive # Retrieve link sharing configuration for SharePoint and OneDrive
$SPOTenantLinkSharing = Get-SPOTenant | Select-Object DefaultSharingLinkType # $SPOTenantLinkSharing Mock Object
return $SPOTenantLinkSharing '7.2.7' = {
Invoke-Command {
& "$((Get-Command -Name "Get-${prefix}Tenant").Name)"
} | Select-Object -Property DefaultSharingLinkType
} }
'7.2.9' {
# Test-GuestAccessExpiration.ps1 # Test-GuestAccessExpiration.ps1
# Retrieve SharePoint tenant settings related to guest access expiration # Retrieve SharePoint tenant settings related to guest access expiration
$SPOTenantGuestAccess = Get-SPOTenant | Select-Object ExternalUserExpirationRequired, ExternalUserExpireInDays # $SPOTenantGuestAccess Mock Object
return $SPOTenantGuestAccess '7.2.9' = {
Invoke-Command {
& "$((Get-Command -Name "Get-${prefix}Tenant").Name)"
} | Select-Object -Property ExternalUserExpirationRequired, ExternalUserExpireInDays
} }
'7.2.10' {
# Test-ReauthWithCode.ps1 # Test-ReauthWithCode.ps1
# 7.2.10 (L1) Ensure reauthentication with verification code is restricted # 7.2.10 (L1) Ensure reauthentication with verification code is restricted
# Retrieve reauthentication settings for SharePoint Online # Retrieve reauthentication settings for SharePoint Online
$SPOTenantReauthentication = Get-SPOTenant | Select-Object EmailAttestationRequired, EmailAttestationReAuthDays # $SPOTenantReauthentication Mock Object
return $SPOTenantReauthentication '7.2.10' = {
Invoke-Command {
& "$((Get-Command -Name "Get-${prefix}Tenant").Name)"
} | Select-Object -Property EmailAttestationRequired, EmailAttestationReAuthDays
} }
'7.3.1' {
# Test-DisallowInfectedFilesDownload.ps1 # Test-DisallowInfectedFilesDownload.ps1
# Retrieve the SharePoint tenant configuration # Retrieve the SharePoint tenant configuration
$SPOTenantDisallowInfectedFileDownload = Get-SPOTenant | Select-Object DisallowInfectedFileDownload # $SPOTenantDisallowInfectedFileDownload Mock Object
return $SPOTenantDisallowInfectedFileDownload '7.3.1' = {
Invoke-Command {
& "$((Get-Command -Name "Get-${prefix}Tenant").Name)"
} | Select-Object -Property DisallowInfectedFileDownload
} }
'7.3.2' {
# Test-OneDriveSyncRestrictions.ps1 # Test-OneDriveSyncRestrictions.ps1
# Retrieve OneDrive sync client restriction settings # Retrieve OneDrive sync client restriction settings
$SPOTenantSyncClientRestriction = Get-SPOTenantSyncClientRestriction | Select-Object TenantRestrictionEnabled, AllowedDomainList # Add isHybrid parameter?
return $SPOTenantSyncClientRestriction # $SPOTenantSyncClientRestriction Mock Object
'7.3.2' = {
Invoke-Command {
& "$((Get-Command -Name "Get-${prefix}TenantSyncClientRestriction").Name)"
} | Select-Object -Property TenantRestrictionEnabled, AllowedDomainList
} }
'7.3.4' {
# Test-RestrictCustomScripts.ps1 # Test-RestrictCustomScripts.ps1
# Retrieve all site collections and select necessary properties # Retrieve all site collections and select necessary properties
$SPOSitesCustomScript = Get-SPOSite -Limit All | Select-Object Title, Url, DenyAddAndCustomizePages # $SPOSitesCustomScript Mock Object
return $SPOSitesCustomScript '7.3.4' = {
Invoke-Command {
if ($prefix -eq "SPO") {
& "$((Get-Command -Name "Get-${prefix}Site").Name)" -Limit All | Select-Object Title, Url, DenyAddAndCustomizePages
} else {
& "$((Get-Command -Name "Get-${prefix}TenantSite").Name)" | Select-Object Title, Url, DenyAddAndCustomizePages
} }
default { throw "No match found for test: $Rec" } }
}
}
}
process {
try {
Write-Verbose "Returning data for Rec: $Rec"
if ($commandMap.ContainsKey($Rec)) {
# Invoke the script block associated with the command
$result = & $commandMap[$Rec] -ErrorAction Stop
return $result
}
else {
throw "No match found for test: $Rec"
}
}
catch {
throw "Get-CISSpoOutput: `n$_"
} }
} }
end { end {
Write-Verbose "Retuning data for Rec: $Rec" Write-Verbose "Finished processing for Rec: $Rec"
} }
} # end function Get-CISMSTeamsOutput }

View File

@@ -4,21 +4,28 @@ function Get-RequiredModule {
param ( param (
[Parameter(Mandatory = $true, ParameterSetName = 'AuditFunction')] [Parameter(Mandatory = $true, ParameterSetName = 'AuditFunction')]
[switch]$AuditFunction, [switch]$AuditFunction,
[Parameter(Mandatory = $true, ParameterSetName = 'SyncFunction')] [Parameter(Mandatory = $true, ParameterSetName = 'SyncFunction')]
[switch]$SyncFunction [switch]$SyncFunction
) )
switch ($PSCmdlet.ParameterSetName) { switch ($PSCmdlet.ParameterSetName) {
'AuditFunction' { 'AuditFunction' {
if (($script:PnpAuth)) {
return @( return @(
@{ ModuleName = "ExchangeOnlineManagement"; RequiredVersion = "3.3.0"; SubModules = @() }, @{ ModuleName = "ExchangeOnlineManagement"; RequiredVersion = "3.3.0"; SubModules = @() },
@{ ModuleName = "AzureAD"; RequiredVersion = "2.0.2.182"; SubModules = @() }, @{ ModuleName = "Microsoft.Graph"; RequiredVersion = "2.4.0"; SubModules = @("DeviceManagement", "Users", "Identity.DirectoryManagement", "Identity.SignIns") },
@{ ModuleName = "Microsoft.Graph"; RequiredVersion = "2.4.0"; SubModules = @("Groups", "DeviceManagement", "Users", "Identity.DirectoryManagement", "Identity.SignIns") }, @{ ModuleName = "PnP.PowerShell"; RequiredVersion = "2.5.0"; SubModules = @() },
@{ ModuleName = "MicrosoftTeams"; RequiredVersion = "5.5.0"; SubModules = @() }
)
}
else {
return @(
@{ ModuleName = "ExchangeOnlineManagement"; RequiredVersion = "3.3.0"; SubModules = @() },
@{ ModuleName = "Microsoft.Graph"; RequiredVersion = "2.4.0"; SubModules = @("DeviceManagement", "Users", "Identity.DirectoryManagement", "Identity.SignIns") },
@{ ModuleName = "Microsoft.Online.SharePoint.PowerShell"; RequiredVersion = "16.0.24009.12000"; SubModules = @() }, @{ ModuleName = "Microsoft.Online.SharePoint.PowerShell"; RequiredVersion = "16.0.24009.12000"; SubModules = @() },
@{ ModuleName = "MicrosoftTeams"; RequiredVersion = "5.5.0"; SubModules = @() } @{ ModuleName = "MicrosoftTeams"; RequiredVersion = "5.5.0"; SubModules = @() }
) )
} }
}
'SyncFunction' { 'SyncFunction' {
return @( return @(
@{ ModuleName = "ImportExcel"; RequiredVersion = "7.8.9"; SubModules = @() } @{ ModuleName = "ImportExcel"; RequiredVersion = "7.8.9"; SubModules = @() }

View File

@@ -27,7 +27,7 @@ function Get-TestError {
$script:FailedTests.Add([PSCustomObject]@{ Rec = $recnum; Description = $description; Error = $LastError }) $script:FailedTests.Add([PSCustomObject]@{ Rec = $recnum; Description = $description; Error = $LastError })
# Call Initialize-CISAuditResult with error parameters # Call Initialize-CISAuditResult with error parameters
$auditResult = Initialize-CISAuditResult -Rec $recnum -Failure $auditResult = Initialize-CISAuditResult -Rec $recnum -Failure
Write-Verbose "An error occurred during the test: `n$LastError" -Verbose Write-Verbose "An error occurred during the test $recnum`: `n$LastError" -Verbose
return $auditResult return $auditResult
} }

View File

@@ -8,10 +8,7 @@ function Get-UniqueConnection {
$uniqueConnections = @() $uniqueConnections = @()
if ($Connections -contains "AzureAD" -or $Connections -contains "AzureAD | EXO" -or $Connections -contains "AzureAD | EXO | Microsoft Graph") { if ($Connections -contains "Microsoft Graph" -or $Connections -contains "AzureAD | EXO | Microsoft Graph" -or $Connections -contains "EXO | Microsoft Graph") {
$uniqueConnections += "AzureAD"
}
if ($Connections -contains "Microsoft Graph" -or $Connections -contains "AzureAD | EXO | Microsoft Graph") {
$uniqueConnections += "Microsoft Graph" $uniqueConnections += "Microsoft Graph"
} }
if ($Connections -contains "EXO" -or $Connections -contains "AzureAD | EXO" -or $Connections -contains "Microsoft Teams | EXO" -or $Connections -contains "AzureAD | EXO | Microsoft Graph") { if ($Connections -contains "EXO" -or $Connections -contains "AzureAD | EXO" -or $Connections -contains "Microsoft Teams | EXO" -or $Connections -contains "AzureAD | EXO | Microsoft Graph") {

View File

@@ -33,7 +33,7 @@ function Invoke-TestFunction {
return $result return $result
} }
catch { catch {
Write-Error "An error occurred during the test: $_" Write-Error "An error occurred during the test $recnum`:: $_"
$script:FailedTests.Add([PSCustomObject]@{ Test = $functionName; Error = $_ }) $script:FailedTests.Add([PSCustomObject]@{ Test = $functionName; Error = $_ })
# Call Initialize-CISAuditResult with error parameters # Call Initialize-CISAuditResult with error parameters

View File

@@ -18,15 +18,15 @@ function Measure-AuditResult {
$passPercentage = if ($totalTests -eq 0) { 0 } else { [math]::Round(($passedTests / $totalTests) * 100, 2) } $passPercentage = if ($totalTests -eq 0) { 0 } else { [math]::Round(($passedTests / $totalTests) * 100, 2) }
# Display the pass percentage to the user # Display the pass percentage to the user
Write-Host "Audit completed. $passedTests out of $totalTests tests passed." -ForegroundColor Cyan Write-Information "Audit completed. $passedTests out of $totalTests tests passed."
Write-Host "Your passing percentage is $passPercentage%." -ForegroundColor Magenta Write-Information "Your passing percentage is $passPercentage%."
# Display details of failed tests # Display details of failed tests
if ($FailedTests.Count -gt 0) { if ($FailedTests.Count -gt 0) {
Write-Host "The following tests failed to complete:" -ForegroundColor Red Write-Verbose "The following tests failed to complete:"
foreach ($failedTest in $FailedTests) { foreach ($failedTest in $FailedTests) {
Write-Host "Test: $($failedTest.Test)" -ForegroundColor Yellow Write-Verbose "Test: $($failedTest.Test)"
Write-Host "Error: $($failedTest.Error)" -ForegroundColor Yellow Write-Verbose "Error: $($failedTest.Error)"
} }
} }
} }

View File

@@ -1,85 +1,95 @@
<# <#
.SYNOPSIS .SYNOPSIS
Exports M365 security audit results to a CSV file or outputs a specific test result as an object. Exports Microsoft 365 security audit results to CSV or Excel files and supports outputting specific test results as objects.
.DESCRIPTION .DESCRIPTION
This function exports M365 security audit results from either an array of CISAuditResult objects or a CSV file. The Export-M365SecurityAuditTable function exports Microsoft 365 security audit results from an array of CISAuditResult objects or a CSV file.
It can export all results to a specified path or output a specific test result as an object. It can export all results to a specified path, output a specific test result as an object, and includes options for exporting results to Excel.
Additionally, it computes hashes for the exported files and includes them in the zip archive for verification purposes.
.PARAMETER AuditResults .PARAMETER AuditResults
An array of CISAuditResult objects containing the audit results. An array of CISAuditResult objects containing the audit results. This parameter is mandatory when exporting from audit results.
.PARAMETER CsvPath .PARAMETER CsvPath
The path to a CSV file containing the audit results. The path to a CSV file containing the audit results. This parameter is mandatory when exporting from a CSV file.
.PARAMETER OutputTestNumber .PARAMETER OutputTestNumber
The test number to output as an object. Valid values are "1.1.1", "1.3.1", "6.1.2", "6.1.3", "7.3.4". The test number to output as an object. Valid values are "1.1.1", "1.3.1", "6.1.2", "6.1.3", "7.3.4". This parameter is used to output a specific test result.
.PARAMETER ExportAllTests .PARAMETER ExportNestedTables
Switch to export all test results. Switch to export all test results. When specified, all test results are exported to the specified path.
.PARAMETER ExportPath .PARAMETER ExportPath
The path where the CSV files will be exported. The path where the CSV or Excel files will be exported. This parameter is mandatory when exporting all tests.
.PARAMETER ExportOriginalTests .PARAMETER ExportOriginalTests
Switch to export the original audit results to a CSV file. Switch to export the original audit results to a CSV file. When specified, the original test results are exported along with the processed results.
.PARAMETER ExportToExcel .PARAMETER ExportToExcel
Switch to export the results to an Excel file. Switch to export the results to an Excel file. When specified, results are exported in Excel format.
.INPUTS .INPUTS
[CISAuditResult[]], [string] [CISAuditResult[]] - An array of CISAuditResult objects.
[string] - A path to a CSV file.
.OUTPUTS .OUTPUTS
[PSCustomObject] [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
# Output object for a single test number from audit results # 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 -ExportNestedTables -AuditResults $object -ExportPath "C:\temp"
# Export all results from audit results to the specified path # 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
# Output object for a single test number from CSV # 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 -ExportNestedTables -CsvPath "C:\temp\auditresultstoday1.csv" -ExportPath "C:\temp"
# Export all results from CSV to the specified path # 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 -ExportNestedTables -AuditResults $object -ExportPath "C:\temp" -ExportOriginalTests
# Export all results from audit results to the specified path along with the original tests # 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 -ExportNestedTables -CsvPath "C:\temp\auditresultstoday1.csv" -ExportPath "C:\temp" -ExportOriginalTests
# Export all results from CSV to the specified path along with the original tests # Exports all audit results from the CSV file along with the original test results to the specified path in CSV format.
.EXAMPLE
Export-M365SecurityAuditTable -ExportNestedTables -AuditResults $object -ExportPath "C:\temp" -ExportToExcel
# 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
#> #>
function Export-M365SecurityAuditTable { function Export-M365SecurityAuditTable {
[CmdletBinding()] [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
[OutputType([PSCustomObject])] [OutputType([PSCustomObject])]
param ( param (
[Parameter(Mandatory = $true, Position = 1, ParameterSetName = "ExportAllResultsFromAuditResults")] [Parameter(Mandatory = $true, Position = 1, ParameterSetName = "ExportAllResultsFromAuditResults")]
[Parameter(Mandatory = $true, Position = 2, ParameterSetName = "OutputObjectFromAuditResultsSingle")] [Parameter(Mandatory = $true, Position = 2, ParameterSetName = "OutputObjectFromAuditResultsSingle")]
[CISAuditResult[]]$AuditResults, [CISAuditResult[]]$AuditResults,
[Parameter(Mandatory = $true, Position = 1, ParameterSetName = "ExportAllResultsFromCsv")] [Parameter(Mandatory = $true, Position = 1, ParameterSetName = "ExportAllResultsFromCsv")]
[Parameter(Mandatory = $true, Position = 2, ParameterSetName = "OutputObjectFromCsvSingle")] [Parameter(Mandatory = $true, Position = 2, ParameterSetName = "OutputObjectFromCsvSingle")]
[ValidateScript({ (Test-Path $_) -and ((Get-Item $_).PSIsContainer -eq $false) })] [ValidateScript({ (Test-Path $_) -and ((Get-Item $_).PSIsContainer -eq $false) })]
[string]$CsvPath, [string]$CsvPath,
[Parameter(Mandatory = $true, Position = 1, ParameterSetName = "OutputObjectFromAuditResultsSingle")] [Parameter(Mandatory = $true, Position = 1, ParameterSetName = "OutputObjectFromAuditResultsSingle")]
[Parameter(Mandatory = $true, Position = 1, ParameterSetName = "OutputObjectFromCsvSingle")] [Parameter(Mandatory = $true, Position = 1, ParameterSetName = "OutputObjectFromCsvSingle")]
[ValidateSet("1.1.1", "1.3.1", "6.1.2", "6.1.3", "7.3.4")] [ValidateSet("1.1.1", "1.3.1", "6.1.2", "6.1.3", "7.3.4")]
[string]$OutputTestNumber, [string]$OutputTestNumber,
[Parameter(Mandatory = $false, Position = 0, ParameterSetName = "ExportAllResultsFromAuditResults")] [Parameter(Mandatory = $false, Position = 0, ParameterSetName = "ExportAllResultsFromAuditResults")]
[Parameter(Mandatory = $false, Position = 0, ParameterSetName = "ExportAllResultsFromCsv")] [Parameter(Mandatory = $false, Position = 0, ParameterSetName = "ExportAllResultsFromCsv")]
[switch]$ExportAllTests, [switch]$ExportNestedTables,
[Parameter(Mandatory = $true, ParameterSetName = "ExportAllResultsFromAuditResults")] [Parameter(Mandatory = $true, ParameterSetName = "ExportAllResultsFromAuditResults")]
[Parameter(Mandatory = $true, ParameterSetName = "ExportAllResultsFromCsv")] [Parameter(Mandatory = $true, ParameterSetName = "ExportAllResultsFromCsv")]
[string]$ExportPath, [string]$ExportPath,
[Parameter(Mandatory = $true, ParameterSetName = "ExportAllResultsFromAuditResults")]
[Parameter(Mandatory = $true, ParameterSetName = "ExportAllResultsFromCsv")]
[switch]$ExportOriginalTests,
[Parameter(Mandatory = $false, ParameterSetName = "ExportAllResultsFromAuditResults")] [Parameter(Mandatory = $false, ParameterSetName = "ExportAllResultsFromAuditResults")]
[Parameter(Mandatory = $false, ParameterSetName = "ExportAllResultsFromCsv")] [Parameter(Mandatory = $false, ParameterSetName = "ExportAllResultsFromCsv")]
[switch]$ExportToExcel [switch]$ExportOriginalTests,
[Parameter(Mandatory = $false, ParameterSetName = "ExportAllResultsFromAuditResults")]
[Parameter(Mandatory = $false, ParameterSetName = "ExportAllResultsFromCsv")]
[switch]$ExportToExcel,
# Add Prefix to filename after date when outputting to excel or csv.
[Parameter(Mandatory = $false, ParameterSetName = "ExportAllResultsFromAuditResults")]
[Parameter(Mandatory = $false, ParameterSetName = "ExportAllResultsFromCsv")]
# Validate that the count of letters in the prefix is less than 5.
[ValidateLength(0, 5)]
[string]$Prefix = "Corp"
) )
Begin {
$createdFiles = @() # Initialize an array to keep track of created files
if ($ExportToExcel) { if ($ExportToExcel) {
if ($PSCmdlet.ShouldProcess("ImportExcel v7.8.9", "Assert-ModuleAvailability")) {
Assert-ModuleAvailability -ModuleName ImportExcel -RequiredVersion "7.8.9" Assert-ModuleAvailability -ModuleName ImportExcel -RequiredVersion "7.8.9"
} }
}
if ($PSCmdlet.ParameterSetName -like "ExportAllResultsFromCsv" -or $PSCmdlet.ParameterSetName -eq "OutputObjectFromCsvSingle") { if ($PSCmdlet.ParameterSetName -like "ExportAllResultsFromCsv" -or $PSCmdlet.ParameterSetName -eq "OutputObjectFromCsvSingle") {
$AuditResults = Import-Csv -Path $CsvPath | ForEach-Object { $AuditResults = Import-Csv -Path $CsvPath | ForEach-Object {
$params = @{ $params = @{
@@ -92,65 +102,28 @@ function Export-M365SecurityAuditTable {
Initialize-CISAuditResult @params Initialize-CISAuditResult @params
} }
} }
if ($ExportNestedTables) {
if ($ExportAllTests) {
$TestNumbers = "1.1.1", "1.3.1", "6.1.2", "6.1.3", "7.3.4" $TestNumbers = "1.1.1", "1.3.1", "6.1.2", "6.1.3", "7.3.4"
} }
$results = @() $results = @()
$testsToProcess = if ($OutputTestNumber) { @($OutputTestNumber) } else { $TestNumbers } $testsToProcess = if ($OutputTestNumber) { @($OutputTestNumber) } else { $TestNumbers }
}
Process {
foreach ($test in $testsToProcess) { foreach ($test in $testsToProcess) {
$auditResult = $AuditResults | Where-Object { $_.Rec -eq $test } $auditResult = $AuditResults | Where-Object { $_.Rec -eq $test }
if (-not $auditResult) { if (-not $auditResult) {
Write-Information "No audit results found for the test number $test." Write-Information "No audit results found for the test number $test."
continue continue
} }
switch ($test) { switch ($test) {
"6.1.2" { "6.1.2" {
$details = $auditResult.Details $details = $auditResult.Details
if ($details -ne "No M365 E3 licenses found.") { $newObjectDetails = Get-AuditMailboxDetail -Details $details -Version '6.1.2'
$csv = $details | ConvertFrom-Csv -Delimiter '|'
}
else {
$csv = $null
}
if ($null -ne $csv) {
foreach ($row in $csv) {
$row.AdminActionsMissing = (Get-Action -AbbreviatedActions $row.AdminActionsMissing.Split(',') -ReverseActionType Admin | Where-Object { $_ -notin @("MailItemsAccessed", "Send") }) -join ','
$row.DelegateActionsMissing = (Get-Action -AbbreviatedActions $row.DelegateActionsMissing.Split(',') -ReverseActionType Delegate | Where-Object { $_ -notin @("MailItemsAccessed") }) -join ','
$row.OwnerActionsMissing = (Get-Action -AbbreviatedActions $row.OwnerActionsMissing.Split(',') -ReverseActionType Owner | Where-Object { $_ -notin @("MailItemsAccessed", "Send") }) -join ','
}
$newObjectDetails = $csv
}
else {
$newObjectDetails = $details
}
$results += [PSCustomObject]@{ TestNumber = $test; Details = $newObjectDetails } $results += [PSCustomObject]@{ TestNumber = $test; Details = $newObjectDetails }
} }
"6.1.3" { "6.1.3" {
$details = $auditResult.Details $details = $auditResult.Details
if ($details -ne "No M365 E5 licenses found.") { $newObjectDetails = Get-AuditMailboxDetail -Details $details -Version '6.1.3'
$csv = $details | ConvertFrom-Csv -Delimiter '|'
}
else {
$csv = $null
}
if ($null -ne $csv) {
foreach ($row in $csv) {
$row.AdminActionsMissing = (Get-Action -AbbreviatedActions $row.AdminActionsMissing.Split(',') -ReverseActionType Admin) -join ','
$row.DelegateActionsMissing = (Get-Action -AbbreviatedActions $row.DelegateActionsMissing.Split(',') -ReverseActionType Delegate) -join ','
$row.OwnerActionsMissing = (Get-Action -AbbreviatedActions $row.OwnerActionsMissing.Split(',') -ReverseActionType Owner) -join ','
}
$newObjectDetails = $csv
}
else {
$newObjectDetails = $details
}
$results += [PSCustomObject]@{ TestNumber = $test; Details = $newObjectDetails } $results += [PSCustomObject]@{ TestNumber = $test; Details = $newObjectDetails }
} }
Default { Default {
@@ -160,26 +133,29 @@ function Export-M365SecurityAuditTable {
} }
} }
} }
}
End {
if ($ExportPath) { if ($ExportPath) {
if ($PSCmdlet.ShouldProcess("Export-M365SecurityAuditTable", "Exporting results to $ExportPath")) {
$timestamp = (Get-Date).ToString("yyyy.MM.dd_HH.mm.ss") $timestamp = (Get-Date).ToString("yyyy.MM.dd_HH.mm.ss")
$exportedTests = @() $exportedTests = @()
foreach ($result in $results) { foreach ($result in $results) {
$testDef = $script:TestDefinitionsObject | Where-Object { $_.Rec -eq $result.TestNumber } $testDef = $script:TestDefinitionsObject | Where-Object { $_.Rec -eq $result.TestNumber }
if ($testDef) { if ($testDef) {
$fileName = "$ExportPath\$($timestamp)_$($result.TestNumber).$($testDef.TestFileName -replace '\.ps1$').csv" $fileName = "$ExportPath\$($timestamp)_$($result.TestNumber).$($testDef.TestFileName -replace '\.ps1$').csv"
if ($result.Details.Count -eq 0) { if ($result.Details.Count -eq 0) {
Write-Information "No results found for test number $($result.TestNumber)." -InformationAction Continue Write-Information "No results found for test number $($result.TestNumber)."
} }
else { else {
if (($result.Details -ne "No M365 E3 licenses found.") -and ($result.Details -ne "No M365 E5 licenses found.")) { if (($result.Details -ne "No M365 E3 licenses found.") -and ($result.Details -ne "No M365 E5 licenses found.")) {
if ($ExportToExcel) { if ($ExportToExcel) {
$xlsxPath = [System.IO.Path]::ChangeExtension($fileName, '.xlsx') $xlsxPath = [System.IO.Path]::ChangeExtension($fileName, '.xlsx')
$result.Details | Export-Excel -Path $xlsxPath -WorksheetName Table -TableName Table -AutoSize -TableStyle Medium2 $result.Details | Export-Excel -Path $xlsxPath -WorksheetName Table -TableName Table -AutoSize -TableStyle Medium2
$createdFiles += $xlsxPath # Add the created file to the array
} }
else { else {
$result.Details | Export-Csv -Path $fileName -NoTypeInformation $result.Details | Export-Csv -Path $fileName -NoTypeInformation
$createdFiles += $fileName # Add the created file to the array
} }
$exportedTests += $result.TestNumber $exportedTests += $result.TestNumber
} }
@@ -187,42 +163,73 @@ function Export-M365SecurityAuditTable {
} }
} }
if ($exportedTests.Count -gt 0) { if ($exportedTests.Count -gt 0) {
Write-Information "The following tests were exported: $($exportedTests -join ', ')" -InformationAction Continue Write-Information "The following tests were exported: $($exportedTests -join ', ')"
} }
else { else {
if ($ExportOriginalTests) { if ($ExportOriginalTests) {
Write-Information "Full audit results exported however, none of the following tests had exports: `n1.1.1, 1.3.1, 6.1.2, 6.1.3, 7.3.4" -InformationAction Continue Write-Information "Full audit results exported however, none of the following tests had exports: `n1.1.1, 1.3.1, 6.1.2, 6.1.3, 7.3.4"
} }
else { else {
Write-Information "No specified tests were included in the export." -InformationAction Continue Write-Information "No specified tests were included in the export."
} }
} }
if ($ExportOriginalTests) { if ($ExportOriginalTests) {
# Define the test numbers to check # Define the test numbers to check
$TestNumbersToCheck = "1.1.1", "1.3.1", "6.1.2", "6.1.3", "7.3.4" $TestNumbersToCheck = "1.1.1", "1.3.1", "6.1.2", "6.1.3", "7.3.4"
# Check for large details and update the AuditResults array # Check for large details and update the AuditResults array
$updatedAuditResults = Get-ExceededLengthResultDetail -AuditResults $AuditResults -TestNumbersToCheck $TestNumbersToCheck -ExportedTests $exportedTests -DetailsLengthLimit 30000 -PreviewLineCount 25 $updatedAuditResults = Get-ExceededLengthResultDetail -AuditResults $AuditResults -TestNumbersToCheck $TestNumbersToCheck -ExportedTests $exportedTests -DetailsLengthLimit 30000 -PreviewLineCount 25
$originalFileName = "$ExportPath\$timestamp`_M365FoundationsAudit.csv" $originalFileName = "$ExportPath\$timestamp`_$Prefix-M365FoundationsAudit.csv"
if ($ExportToExcel) { if ($ExportToExcel) {
$xlsxPath = [System.IO.Path]::ChangeExtension($originalFileName, '.xlsx') $xlsxPath = [System.IO.Path]::ChangeExtension($originalFileName, '.xlsx')
$updatedAuditResults | Export-Excel -Path $xlsxPath -WorksheetName Table -TableName Table -AutoSize -TableStyle Medium2 $updatedAuditResults | Export-Excel -Path $xlsxPath -WorksheetName Table -TableName Table -AutoSize -TableStyle Medium2
$createdFiles += $xlsxPath # Add the created file to the array
} }
else { else {
$updatedAuditResults | Export-Csv -Path $originalFileName -NoTypeInformation $updatedAuditResults | Export-Csv -Path $originalFileName -NoTypeInformation
$createdFiles += $originalFileName # Add the created file to the array
} }
} }
# Hash each file and add it to a dictionary
# Hash each file and save the hashes to a text file
$hashFilePath = "$ExportPath\$timestamp`_Hashes.txt"
$fileHashes = @()
foreach ($file in $createdFiles) {
$hash = Get-FileHash -Path $file -Algorithm SHA256
$fileHashes += "$($file): $($hash.Hash)"
} }
$fileHashes | Set-Content -Path $hashFilePath
$createdFiles += $hashFilePath # Add the hash file to the array
# Create a zip file and add all the created files
$zipFilePath = "$ExportPath\$timestamp`_$Prefix-M365FoundationsAudit.zip"
Compress-Archive -Path $createdFiles -DestinationPath $zipFilePath
# Remove the original files after they have been added to the zip
foreach ($file in $createdFiles) {
Remove-Item -Path $file -Force
}
# Compute the hash for the zip file and rename it
$zipHash = Get-FileHash -Path $zipFilePath -Algorithm SHA256
$newZipFilePath = "$ExportPath\$timestamp`_$Prefix-M365FoundationsAudit_$($zipHash.Hash.Substring(0, 8)).zip"
Rename-Item -Path $zipFilePath -NewName $newZipFilePath
# Output the zip file path with hash
return [PSCustomObject]@{
ZipFilePath = $newZipFilePath
}
}
} # End of ExportPath
elseif ($OutputTestNumber) { elseif ($OutputTestNumber) {
if ($results[0].Details) { if ($results[0].Details) {
return $results[0].Details return $results[0].Details
} }
else { else {
Write-Information "No results found for test number $($OutputTestNumber)." -InformationAction Continue Write-Information "No results found for test number $($OutputTestNumber)."
} }
} }
else { else {
Write-Error "No valid operation specified. Please provide valid parameters." Write-Error "No valid operation specified. Please provide valid parameters."
} }
# Output the created files at the end
#if ($createdFiles.Count -gt 0) {
########### $createdFiles
#}
}
} }

View File

@@ -2,15 +2,17 @@
.SYNOPSIS .SYNOPSIS
Invokes a security audit for Microsoft 365 environments. Invokes a security audit for Microsoft 365 environments.
.DESCRIPTION .DESCRIPTION
The Invoke-M365SecurityAudit cmdlet performs a comprehensive security audit based on the specified parameters. It allows auditing of various configurations and settings within a Microsoft 365 environment, such as compliance with CIS benchmarks. The Invoke-M365SecurityAudit cmdlet performs a comprehensive security audit based on the specified parameters.
It allows auditing of various configurations and settings within a Microsoft 365 environment in alignment with CIS benchmarks designated "Automatic".
.PARAMETER TenantAdminUrl .PARAMETER TenantAdminUrl
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. This parameter is not mandatory and by default it will pass/fail all found domains as a group if a specific domain is not specified. 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
.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
Specifies the profile level (L1 or L2) for the audit. This parameter is optional and can be combined with the ELevel parameter. Specifies the profile level (L1 or L2) for the audit. This parameter is mandatory, but only when ELevel is selected. Otherwise it is not required.
.PARAMETER IncludeIG1 .PARAMETER IncludeIG1
If specified, includes tests where IG1 is true. If specified, includes tests where IG1 is true.
.PARAMETER IncludeIG2 .PARAMETER IncludeIG2
@@ -22,9 +24,11 @@
.PARAMETER SkipRecommendation .PARAMETER SkipRecommendation
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. 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'
.PARAMETER ApprovedFederatedDomains .PARAMETER ApprovedFederatedDomains
Specifies the approved federated domains for the audit test 8.2.1. 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.
.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
@@ -33,80 +37,40 @@
If specified, the cmdlet will not check for the presence of required modules. If specified, the cmdlet will not check for the presence of required modules.
.PARAMETER DoNotConfirmConnections .PARAMETER DoNotConfirmConnections
If specified, the cmdlet will not prompt for confirmation before proceeding with established connections and will disconnect from all of them. If specified, the cmdlet will not prompt for confirmation before proceeding with established connections and will disconnect from all of them.
.PARAMETER AuthParams
Specifies an authentication object containing parameters for application-based authentication. If provided, this will be used for connecting to services.
.EXAMPLE .EXAMPLE
PS> Invoke-M365SecurityAudit PS> Invoke-M365SecurityAudit
# Performs a security audit using default parameters.
Performs a security audit using default parameters.
Output:
Status : Fail
ELevel : E3
ProfileLevel: L1
Connection : Microsoft Graph
Rec : 1.1.1
Result : False
Details : Non-compliant accounts:
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> 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:
Status : Fail
ELevel : E5
ProfileLevel: L1
Connection : Microsoft Graph
Rec : 1.1.1
Result : False
Details : Non-compliant accounts:
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> 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 a security audit while including tests where IG1 is true.
Performs an audit including all tests where IG1 is true.
Output:
Status : Fail
ELevel : E3
ProfileLevel: L1
Connection : Microsoft Graph
Rec : 1.1.1
Result : False
Details : Non-compliant accounts:
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> 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. # Performs an audit while excluding specific recommendations 1.1.3 and 2.1.1.
Output:
Status : Fail
ELevel : E3
ProfileLevel: L1
Connection : Microsoft Graph
Rec : 1.1.1
Result : False
Details : Non-compliant accounts:
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> Export-M365SecurityAuditTable -AuditResults $auditResults -ExportPath "C:\temp" -ExportOriginalTests -ExportAllTests
.EXAMPLE
# (PowerShell 7.x Only) Creating a new authentication object for the security audit for app-based authentication.
PS> $authParams = New-M365SecurityAuditAuthObject `
-ClientCertThumbPrint "ABCDEF1234567890ABCDEF1234567890ABCDEF12" `
-ClientId "12345678-1234-1234-1234-123456789012" `
-TenantId "12345678-1234-1234-1234-123456789012" `
-OnMicrosoftUrl "yourcompany.onmicrosoft.com" `
-SpAdminUrl "https://yourcompany-admin.sharepoint.com"
Invoke-M365SecurityAudit -AuthParams $authParams -TenantAdminUrl "https://yourcompany-admin.sharepoint.com"
# Or:
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 (Nested tables will be truncated).
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".
@@ -126,36 +90,30 @@
https://criticalsolutionsnetwork.github.io/M365FoundationsCISReport/#Invoke-M365SecurityAudit https://criticalsolutionsnetwork.github.io/M365FoundationsCISReport/#Invoke-M365SecurityAudit
#> #>
function Invoke-M365SecurityAudit { function Invoke-M365SecurityAudit {
[CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'Default')] # Add confirm to high
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = "High" , DefaultParameterSetName = 'Default')]
[OutputType([CISAuditResult[]])] [OutputType([CISAuditResult[]])]
param ( param (
[Parameter(Mandatory = $false, HelpMessage = "The SharePoint tenant admin URL, which should end with '-admin.sharepoint.com'. If not specified none of the Sharepoint Online tests will run.")] [Parameter(Mandatory = $false, HelpMessage = "The SharePoint tenant admin URL, which should end with '-admin.sharepoint.com'. If not specified none of the Sharepoint Online tests will run.")]
[ValidatePattern('^https://[a-zA-Z0-9-]+-admin\.sharepoint\.com$')] [ValidatePattern('^https://[a-zA-Z0-9-]+-admin\.sharepoint\.com$')]
[string]$TenantAdminUrl, [string]$TenantAdminUrl,
[Parameter(Mandatory = $false, HelpMessage = "Specify this to test only the default domain for password expiration and DKIM Config for tests '1.3.1' and 2.1.9. The domain name of your organization, e.g., 'example.com'.")] [Parameter(Mandatory = $false, HelpMessage = "Specify this to test only the default domain for password expiration and DKIM Config for tests '1.3.1' and 2.1.9. The domain name of your organization, e.g., 'example.com'.")]
[ValidatePattern('^[a-zA-Z0-9-]+\.[a-zA-Z]{2,}$')] [ValidatePattern('^[a-zA-Z0-9-]+\.[a-zA-Z]{2,}$')]
[string]$DomainName, [string]$DomainName,
# E-Level with optional ProfileLevel selection # E-Level with optional ProfileLevel selection
[Parameter(Mandatory = $true, ParameterSetName = 'ELevelFilter', HelpMessage = "Specifies the E-Level (E3 or E5) for the audit.")] [Parameter(Mandatory = $true, ParameterSetName = 'ELevelFilter', HelpMessage = "Specifies the E-Level (E3 or E5) for the audit.")]
[ValidateSet('E3', 'E5')] [ValidateSet('E3', 'E5')]
[string]$ELevel, [string]$ELevel,
[Parameter(Mandatory = $true, ParameterSetName = 'ELevelFilter', HelpMessage = "Specifies the profile level (L1 or L2) for the audit.")] [Parameter(Mandatory = $true, ParameterSetName = 'ELevelFilter', HelpMessage = "Specifies the profile level (L1 or L2) for the audit.")]
[ValidateSet('L1', 'L2')] [ValidateSet('L1', 'L2')]
[string]$ProfileLevel, [string]$ProfileLevel,
# IG Filters, one at a time # IG Filters, one at a time
[Parameter(Mandatory = $true, ParameterSetName = 'IG1Filter', HelpMessage = "Includes tests where IG1 is true.")] [Parameter(Mandatory = $true, ParameterSetName = 'IG1Filter', HelpMessage = "Includes tests where IG1 is true.")]
[switch]$IncludeIG1, [switch]$IncludeIG1,
[Parameter(Mandatory = $true, ParameterSetName = 'IG2Filter', HelpMessage = "Includes tests where IG2 is true.")] [Parameter(Mandatory = $true, ParameterSetName = 'IG2Filter', HelpMessage = "Includes tests where IG2 is true.")]
[switch]$IncludeIG2, [switch]$IncludeIG2,
[Parameter(Mandatory = $true, ParameterSetName = 'IG3Filter', HelpMessage = "Includes tests where IG3 is true.")] [Parameter(Mandatory = $true, ParameterSetName = 'IG3Filter', HelpMessage = "Includes tests where IG3 is true.")]
[switch]$IncludeIG3, [switch]$IncludeIG3,
# Inclusion of specific recommendation numbers # Inclusion of specific recommendation numbers
[Parameter(Mandatory = $true, ParameterSetName = 'RecFilter', HelpMessage = "Specifies specific recommendations to include in the audit. Accepts an array of recommendation numbers.")] [Parameter(Mandatory = $true, ParameterSetName = 'RecFilter', HelpMessage = "Specifies specific recommendations to include in the audit. Accepts an array of recommendation numbers.")]
[ValidateSet( [ValidateSet(
@@ -168,7 +126,6 @@ function Invoke-M365SecurityAudit {
'8.5.7', '8.6.1' '8.5.7', '8.6.1'
)] )]
[string[]]$IncludeRecommendation, [string[]]$IncludeRecommendation,
# Exclusion of specific recommendation numbers # Exclusion of specific recommendation numbers
[Parameter(Mandatory = $true, ParameterSetName = 'SkipRecFilter', HelpMessage = "Specifies specific recommendations to exclude from the audit. Accepts an array of recommendation numbers.")] [Parameter(Mandatory = $true, ParameterSetName = 'SkipRecFilter', HelpMessage = "Specifies specific recommendations to exclude from the audit. Accepts an array of recommendation numbers.")]
[ValidateSet( [ValidateSet(
@@ -181,53 +138,50 @@ function Invoke-M365SecurityAudit {
'8.5.7', '8.6.1' '8.5.7', '8.6.1'
)] )]
[string[]]$SkipRecommendation, [string[]]$SkipRecommendation,
# Common parameters for all parameter sets # Common parameters for all parameter sets
[Parameter(Mandatory = $false, HelpMessage = "Specifies the approved cloud storage providers for the audit. Accepts an array of cloud storage provider names.")] [Parameter(Mandatory = $false, HelpMessage = "Specifies the approved cloud storage providers for the audit. Accepts an array of cloud storage provider names.")]
[ValidateSet( [ValidateSet(
'GoogleDrive', 'ShareFile', 'Box', 'DropBox', 'Egnyte' 'GoogleDrive', 'ShareFile', 'Box', 'DropBox', 'Egnyte'
)] )]
[string[]]$ApprovedCloudStorageProviders = @(), [string[]]$ApprovedCloudStorageProviders = @(),
[Parameter(Mandatory = $false, HelpMessage = "Specifies the approved federated domains for the audit test 8.2.1. Accepts an array of allowed domain names.")] [Parameter(Mandatory = $false, HelpMessage = "Specifies the approved federated domains for the audit test 8.2.1. Accepts an array of allowed domain names.")]
[ValidatePattern('^[a-zA-Z0-9-]+\.[a-zA-Z]{2,}$')]
[string[]]$ApprovedFederatedDomains, [string[]]$ApprovedFederatedDomains,
[Parameter(Mandatory = $false, HelpMessage = "Specifies that the cmdlet will not establish a connection to Microsoft 365 services.")] [Parameter(Mandatory = $false, HelpMessage = "Specifies that the cmdlet will not establish a connection to Microsoft 365 services.")]
[switch]$DoNotConnect, [switch]$DoNotConnect,
[Parameter(Mandatory = $false, HelpMessage = "Specifies that the cmdlet will not disconnect from Microsoft 365 services after execution.")] [Parameter(Mandatory = $false, HelpMessage = "Specifies that the cmdlet will not disconnect from Microsoft 365 services after execution.")]
[switch]$DoNotDisconnect, [switch]$DoNotDisconnect,
[Parameter(Mandatory = $false, HelpMessage = "Specifies that the cmdlet will not check for the presence of required modules.")] [Parameter(Mandatory = $false, HelpMessage = "Specifies that the cmdlet will not check for the presence of required modules.")]
[switch]$NoModuleCheck, [switch]$NoModuleCheck,
[Parameter(Mandatory = $false, HelpMessage = "Specifies that the cmdlet will not prompt for confirmation before proceeding with established connections and will disconnect from all of them.")] [Parameter(Mandatory = $false, HelpMessage = "Specifies that the cmdlet will not prompt for confirmation before proceeding with established connections and will disconnect from all of them.")]
[switch]$DoNotConfirmConnections [switch]$DoNotConfirmConnections,
[Parameter(Mandatory = $false, HelpMessage = "Specifies an authentication object containing parameters for application-based authentication.")]
[CISAuthenticationParameters]$AuthParams
) )
Begin { Begin {
if ($script:MaximumFunctionCount -lt 8192) { if ($script:MaximumFunctionCount -lt 8192) {
Write-Verbose "Setting the `$script:MaximumFunctionCount to 8192 for the test run."
$script:MaximumFunctionCount = 8192 $script:MaximumFunctionCount = 8192
} }
if ($AuthParams) {
$script:PnpAuth = $true
}
# Ensure required modules are installed # Ensure required modules are installed
$requiredModules = Get-RequiredModule -AuditFunction $requiredModules = Get-RequiredModule -AuditFunction
# Format the required modules list # Format the required modules list
$requiredModulesFormatted = Format-RequiredModuleList -RequiredModules $requiredModules $requiredModulesFormatted = Format-RequiredModuleList -RequiredModules $requiredModules
# Check and install required modules if necessary # Check and install required modules if necessary
if (!($NoModuleCheck) -and $PSCmdlet.ShouldProcess("Check for required modules: $requiredModulesFormatted", "Check")) { if (!($NoModuleCheck) -and $PSCmdlet.ShouldProcess("Modules: $requiredModulesFormatted", "Assert-ModuleAvailability")) {
Write-Host "Checking for and installing required modules..." -ForegroundColor DarkMagenta Write-Information "Checking for and installing required modules..."
foreach ($module in $requiredModules) { foreach ($module in $requiredModules) {
Assert-ModuleAvailability -ModuleName $module.ModuleName -RequiredVersion $module.RequiredVersion -SubModules $module.SubModules Assert-ModuleAvailability -ModuleName $module.ModuleName -RequiredVersion $module.RequiredVersion -SubModules $module.SubModules
} }
} }
# Load test definitions from CSV # Load test definitions from CSV
$testDefinitionsPath = Join-Path -Path $PSScriptRoot -ChildPath "helper\TestDefinitions.csv" $testDefinitionsPath = Join-Path -Path $PSScriptRoot -ChildPath "helper\TestDefinitions.csv"
$testDefinitions = Import-Csv -Path $testDefinitionsPath $testDefinitions = Import-Csv -Path $testDefinitionsPath
# Load the Test Definitions into the script scope for use in other functions # Load the Test Definitions into the script scope for use in other functions
$script:TestDefinitionsObject = $testDefinitions $script:TestDefinitionsObject = $testDefinitions
# Apply filters based on parameter sets # Apply filters based on parameter sets
$params = @{ $params = @{
TestDefinitions = $testDefinitions TestDefinitions = $testDefinitions
@@ -256,33 +210,28 @@ function Invoke-M365SecurityAudit {
# Initialize a collection to hold failed test details # Initialize a collection to hold failed test details
$script:FailedTests = [System.Collections.ArrayList]::new() $script:FailedTests = [System.Collections.ArrayList]::new()
} # End Begin } # End Begin
Process { Process {
$allAuditResults = [System.Collections.ArrayList]::new() # Initialize a collection to hold all results $allAuditResults = [System.Collections.ArrayList]::new() # Initialize a collection to hold all results
# Dynamically dot-source the test scripts # Dynamically dot-source the test scripts
$testsFolderPath = Join-Path -Path $PSScriptRoot -ChildPath "tests" $testsFolderPath = Join-Path -Path $PSScriptRoot -ChildPath "tests"
$testFiles = Get-ChildItem -Path $testsFolderPath -Filter "Test-*.ps1" | $testFiles = Get-ChildItem -Path $testsFolderPath -Filter "Test-*.ps1" |
Where-Object { $testsToLoad -contains $_.BaseName } Where-Object { $testsToLoad -contains $_.BaseName }
$totalTests = $testFiles.Count $totalTests = $testFiles.Count
$currentTestIndex = 0 $currentTestIndex = 0
# Establishing connections if required # Establishing connections if required
try { try {
$actualUniqueConnections = Get-UniqueConnection -Connections $requiredConnections $actualUniqueConnections = Get-UniqueConnection -Connections $requiredConnections
if (!($DoNotConnect) -and $PSCmdlet.ShouldProcess("Establish connections to Microsoft 365 services: $($actualUniqueConnections -join ', ')", "Connect")) { if (!($DoNotConnect) -and $PSCmdlet.ShouldProcess("Establish connections to Microsoft 365 services: $($actualUniqueConnections -join ', ')", "Connect")) {
Write-Host "Establishing connections to Microsoft 365 services: $($actualUniqueConnections -join ', ')" -ForegroundColor DarkMagenta Write-Information "Establishing connections to Microsoft 365 services: $($actualUniqueConnections -join ', ')"
Connect-M365Suite -TenantAdminUrl $TenantAdminUrl -RequiredConnections $requiredConnections -SkipConfirmation:$DoNotConfirmConnections Connect-M365Suite -TenantAdminUrl $TenantAdminUrl -RequiredConnections $requiredConnections -SkipConfirmation:$DoNotConfirmConnections -AuthParams $AuthParams
} }
} }
catch { catch {
Write-Host "Connection execution aborted: $_" -ForegroundColor Red Throw "Connection execution aborted: $_"
break
} }
try { try {
Write-Host "A total of $($totalTests) tests were selected to run..." -ForegroundColor DarkMagenta if ($PSCmdlet.ShouldProcess("Measure and display audit results for $($totalTests) tests", "Measure")) {
Write-Information "A total of $($totalTests) tests were selected to run..."
# Import the test functions # Import the test functions
$testFiles | ForEach-Object { $testFiles | ForEach-Object {
$currentTestIndex++ $currentTestIndex++
@@ -293,27 +242,39 @@ function Invoke-M365SecurityAudit {
} }
Catch { Catch {
# Log the error and add the test to the failed tests collection # Log the error and add the test to the failed tests collection
Write-Verbose "Failed to load test function $($_.Name): $_" -Verbose Write-Verbose "Failed to load test function $($_.Name): $_"
$script:FailedTests.Add([PSCustomObject]@{ Test = $_.Name; Error = $_ }) $script:FailedTests.Add([PSCustomObject]@{ Test = $_.Name; Error = $_ })
} }
} }
$currentTestIndex = 0 $currentTestIndex = 0
# Execute each test function from the prepared list # Execute each test function from the prepared list
foreach ($testFunction in $testFiles) { foreach ($testFunction in $testFiles) {
$currentTestIndex++ $currentTestIndex++
Write-Progress -Activity "Executing Tests" -Status "Executing $($currentTestIndex) of $($totalTests): $($testFunction.Name)" -PercentComplete (($currentTestIndex / $totalTests) * 100) Write-Progress -Activity "Executing Tests" -Status "Executing $($currentTestIndex) of $($totalTests): $($testFunction.Name)" -PercentComplete (($currentTestIndex / $totalTests) * 100)
$functionName = $testFunction.BaseName $functionName = $testFunction.BaseName
if ($PSCmdlet.ShouldProcess($functionName, "Execute test")) { Write-Information "Executing test function: $functionName"
$auditResult = Invoke-TestFunction -FunctionFile $testFunction -DomainName $DomainName -ApprovedCloudStorageProviders $ApprovedCloudStorageProviders -ApprovedFederatedDomains $ApprovedFederatedDomains $auditResult = Invoke-TestFunction -FunctionFile $testFunction -DomainName $DomainName -ApprovedCloudStorageProviders $ApprovedCloudStorageProviders -ApprovedFederatedDomains $ApprovedFederatedDomains
# Add the result to the collection # Add the result to the collection
[void]$allAuditResults.Add($auditResult) [void]$allAuditResults.Add($auditResult)
} }
# Call the private function to calculate and display results
Measure-AuditResult -AllAuditResults $allAuditResults -FailedTests $script:FailedTests
# Return all collected audit results
# Define the test numbers to check
$TestNumbersToCheck = "1.1.1", "1.3.1", "6.1.2", "6.1.3", "7.3.4"
# Check for large details in the audit results
$exceedingTests = Get-ExceededLengthResultDetail -AuditResults $allAuditResults -TestNumbersToCheck $TestNumbersToCheck -ReturnExceedingTestsOnly -DetailsLengthLimit 30000
if ($exceedingTests.Count -gt 0) {
Write-Information "The following tests exceeded the details length limit: $($exceedingTests -join ', ')"
Write-Information "( Assuming the results were instantiated. Ex: `$object = invoke-M365SecurityAudit )`nUse the following command and adjust as necessary to view the full details of the test results:"
Write-Information "Export-M365SecurityAuditTable -ExportAllTests -AuditResults `$object -ExportPath `"C:\temp`" -ExportOriginalTests"
}
return $allAuditResults.ToArray() | Sort-Object -Property Rec
} }
} }
catch { catch {
# Log the error and add the test to the failed tests collection # Log the error and add the test to the failed tests collection
Write-Verbose "Invoke-M365SecurityAudit: Failed to load test function $($_.Name): $_" -Verbose throw "Failed to execute test function $($testFunction.Name): $_"
$script:FailedTests.Add([PSCustomObject]@{ Test = $_.Name; Error = $_ }) $script:FailedTests.Add([PSCustomObject]@{ Test = $_.Name; Error = $_ })
} }
finally { finally {
@@ -324,24 +285,6 @@ function Invoke-M365SecurityAudit {
} }
} }
End { End {
if ($PSCmdlet.ShouldProcess("Measure and display audit results for $($totalTests) tests", "Measure")) {
# Call the private function to calculate and display results
Measure-AuditResult -AllAuditResults $allAuditResults -FailedTests $script:FailedTests
# Return all collected audit results
# Define the test numbers to check
$TestNumbersToCheck = "1.1.1", "1.3.1", "6.1.2", "6.1.3", "7.3.4"
# Check for large details in the audit results
$exceedingTests = Get-ExceededLengthResultDetail -AuditResults $allAuditResults -TestNumbersToCheck $TestNumbersToCheck -ReturnExceedingTestsOnly -DetailsLengthLimit 30000
if ($exceedingTests.Count -gt 0) {
Write-Information "The following tests exceeded the details length limit: $($exceedingTests -join ', ')" -InformationAction Continue
Write-Host "(Assuming the results were instantiated. Ex: `$object = invoke-M365SecurityAudit) Use the following command and adjust as neccesary to view the full details of the test results:" -ForegroundColor DarkCyan
Write-Host "Export-M365SecurityAuditTable -ExportAllTests -AuditResults `$object -ExportPath `"C:\temp`" -ExportOriginalTests" -ForegroundColor Green
}
return $allAuditResults.ToArray() | Sort-Object -Property Rec
}
} }
} }

View File

@@ -0,0 +1,64 @@
<#
.SYNOPSIS
Creates a new CISAuthenticationParameters object for Microsoft 365 authentication.
.DESCRIPTION
The New-M365SecurityAuditAuthObject function constructs a new CISAuthenticationParameters object
containing the necessary credentials and URLs for authenticating to various Microsoft 365 services.
It validates input parameters to ensure they conform to expected formats and length requirements.
An app registration in Azure AD with the required permissions to EXO, SPO, MSTeams and MgGraph is needed.
.PARAMETER ClientCertThumbPrint
The thumbprint of the client certificate used for authentication. It must be a 40-character hexadecimal string.
This certificate is used to authenticate the application in Azure AD.
.PARAMETER ClientId
The Client ID (Application ID) of the Azure AD application. It must be a valid GUID format.
.PARAMETER TenantId
The Tenant ID of the Azure AD directory. It must be a valid GUID format representing your Microsoft 365 tenant.
.PARAMETER OnMicrosoftUrl
The URL of your onmicrosoft.com domain. It should be in the format 'example.onmicrosoft.com'.
.PARAMETER SpAdminUrl
The SharePoint admin URL, which should end with '-admin.sharepoint.com'. This URL is used for connecting to SharePoint Online.
.INPUTS
None. You cannot pipe objects to this function.
.OUTPUTS
CISAuthenticationParameters
The function returns an instance of the CISAuthenticationParameters class containing the authentication details.
.EXAMPLE
PS> $authParams = New-M365SecurityAuditAuthObject -ClientCertThumbPrint "ABCDEF1234567890ABCDEF1234567890ABCDEF12" `
-ClientId "12345678-1234-1234-1234-123456789012" `
-TenantId "12345678-1234-1234-1234-123456789012" `
-OnMicrosoftUrl "yourcompany.onmicrosoft.com" `
-SpAdminUrl "https://yourcompany-admin.sharepoint.com"
Creates a new CISAuthenticationParameters object with the specified credentials and URLs, validating each parameter's format and length.
.NOTES
Requires PowerShell 7.0 or later.
#>
function New-M365SecurityAuditAuthObject {
[CmdletBinding()]
[OutputType([CISAuthenticationParameters])]
param(
[Parameter(Mandatory = $true, HelpMessage = "The 40-character hexadecimal thumbprint of the client certificate.")]
[ValidatePattern("^[0-9a-fA-F]{40}$")] # Regex for a valid thumbprint format
[ValidateLength(40, 40)] # Enforce exact length
[string]$ClientCertThumbPrint,
[Parameter(Mandatory = $true, HelpMessage = "The Client ID (GUID format) of the Azure AD application.")]
[ValidatePattern("^[0-9a-fA-F\-]{36}$")] # Regex for a valid GUID
[string]$ClientId,
[Parameter(Mandatory = $true, HelpMessage = "The Tenant ID (GUID format) of the Azure AD directory.")]
[ValidatePattern("^[0-9a-fA-F\-]{36}$")] # Regex for a valid GUID
[string]$TenantId,
[Parameter(Mandatory = $true, HelpMessage = "The onmicrosoft.com domain URL (e.g., 'example.onmicrosoft.com').")]
[ValidatePattern("^[a-zA-Z0-9]+\.onmicrosoft\.com$")] # Regex for a valid onmicrosoft.com URL
[string]$OnMicrosoftUrl,
[Parameter(Mandatory = $true, HelpMessage = "The SharePoint admin URL ending with '-admin.sharepoint.com'.")]
[ValidatePattern("^https:\/\/[a-zA-Z0-9\-]+\-admin\.sharepoint\.com$")] # Regex for a valid SharePoint admin URL
[string]$SpAdminUrl
)
# Create and return the authentication parameters object
return [CISAuthenticationParameters]::new(
$ClientCertThumbPrint,
$ClientId,
$TenantId,
$OnMicrosoftUrl,
$SpAdminUrl
)
}

View File

@@ -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"
} }

View File

@@ -39,13 +39,47 @@
</dev:type> </dev:type>
<dev:defaultValue>None</dev:defaultValue> <dev:defaultValue>None</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi">
<maml:name>WhatIf</maml:name>
<maml:description>
<maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para>
</maml:description>
<dev:type>
<maml:name>SwitchParameter</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf">
<maml:name>Confirm</maml:name>
<maml:description>
<maml:para>Prompts you for confirmation before running the cmdlet.</maml:para>
</maml:description>
<dev:type>
<maml:name>SwitchParameter</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="proga">
<maml:name>ProgressAction</maml:name>
<maml:description>
<maml:para>{{ Fill ProgressAction Description }}</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">ActionPreference</command:parameterValue>
<dev:type>
<maml:name>ActionPreference</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
</command:syntaxItem> </command:syntaxItem>
<command:syntaxItem> <command:syntaxItem>
<maml:name>Export-M365SecurityAuditTable</maml:name> <maml:name>Export-M365SecurityAuditTable</maml:name>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none">
<maml:name>ExportAllTests</maml:name> <maml:name>ExportNestedTables</maml:name>
<maml:description> <maml:description>
<maml:para>Switch to export all test results.</maml:para> <maml:para>Switch to export all test results. When specified, all test results are exported to the specified path.</maml:para>
</maml:description> </maml:description>
<dev:type> <dev:type>
<maml:name>SwitchParameter</maml:name> <maml:name>SwitchParameter</maml:name>
@@ -77,7 +111,7 @@
</dev:type> </dev:type>
<dev:defaultValue>None</dev:defaultValue> <dev:defaultValue>None</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>ExportOriginalTests</maml:name> <maml:name>ExportOriginalTests</maml:name>
<maml:description> <maml:description>
<maml:para>Switch to export the original audit results to a CSV file.</maml:para> <maml:para>Switch to export the original audit results to a CSV file.</maml:para>
@@ -99,6 +133,52 @@
</dev:type> </dev:type>
<dev:defaultValue>False</dev:defaultValue> <dev:defaultValue>False</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>Prefix</maml:name>
<maml:description>
<maml:para>Add Prefix to filename after date when outputting to excel or csv. Validate that the count of letters in the prefix is less than 5.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>Corp</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi">
<maml:name>WhatIf</maml:name>
<maml:description>
<maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para>
</maml:description>
<dev:type>
<maml:name>SwitchParameter</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf">
<maml:name>Confirm</maml:name>
<maml:description>
<maml:para>Prompts you for confirmation before running the cmdlet.</maml:para>
</maml:description>
<dev:type>
<maml:name>SwitchParameter</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="proga">
<maml:name>ProgressAction</maml:name>
<maml:description>
<maml:para>{{ Fill ProgressAction Description }}</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">ActionPreference</command:parameterValue>
<dev:type>
<maml:name>ActionPreference</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
</command:syntaxItem> </command:syntaxItem>
<command:syntaxItem> <command:syntaxItem>
<maml:name>Export-M365SecurityAuditTable</maml:name> <maml:name>Export-M365SecurityAuditTable</maml:name>
@@ -126,13 +206,47 @@
</dev:type> </dev:type>
<dev:defaultValue>None</dev:defaultValue> <dev:defaultValue>None</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi">
<maml:name>WhatIf</maml:name>
<maml:description>
<maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para>
</maml:description>
<dev:type>
<maml:name>SwitchParameter</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf">
<maml:name>Confirm</maml:name>
<maml:description>
<maml:para>Prompts you for confirmation before running the cmdlet.</maml:para>
</maml:description>
<dev:type>
<maml:name>SwitchParameter</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="proga">
<maml:name>ProgressAction</maml:name>
<maml:description>
<maml:para>{{ Fill ProgressAction Description }}</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">ActionPreference</command:parameterValue>
<dev:type>
<maml:name>ActionPreference</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
</command:syntaxItem> </command:syntaxItem>
<command:syntaxItem> <command:syntaxItem>
<maml:name>Export-M365SecurityAuditTable</maml:name> <maml:name>Export-M365SecurityAuditTable</maml:name>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none">
<maml:name>ExportAllTests</maml:name> <maml:name>ExportNestedTables</maml:name>
<maml:description> <maml:description>
<maml:para>Switch to export all test results.</maml:para> <maml:para>Switch to export all test results. When specified, all test results are exported to the specified path.</maml:para>
</maml:description> </maml:description>
<dev:type> <dev:type>
<maml:name>SwitchParameter</maml:name> <maml:name>SwitchParameter</maml:name>
@@ -164,7 +278,7 @@
</dev:type> </dev:type>
<dev:defaultValue>None</dev:defaultValue> <dev:defaultValue>None</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>ExportOriginalTests</maml:name> <maml:name>ExportOriginalTests</maml:name>
<maml:description> <maml:description>
<maml:para>Switch to export the original audit results to a CSV file.</maml:para> <maml:para>Switch to export the original audit results to a CSV file.</maml:para>
@@ -186,6 +300,52 @@
</dev:type> </dev:type>
<dev:defaultValue>False</dev:defaultValue> <dev:defaultValue>False</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>Prefix</maml:name>
<maml:description>
<maml:para>Add Prefix to filename after date when outputting to excel or csv. Validate that the count of letters in the prefix is less than 5.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>Corp</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi">
<maml:name>WhatIf</maml:name>
<maml:description>
<maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para>
</maml:description>
<dev:type>
<maml:name>SwitchParameter</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf">
<maml:name>Confirm</maml:name>
<maml:description>
<maml:para>Prompts you for confirmation before running the cmdlet.</maml:para>
</maml:description>
<dev:type>
<maml:name>SwitchParameter</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="proga">
<maml:name>ProgressAction</maml:name>
<maml:description>
<maml:para>{{ Fill ProgressAction Description }}</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">ActionPreference</command:parameterValue>
<dev:type>
<maml:name>ActionPreference</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
</command:syntaxItem> </command:syntaxItem>
</command:syntax> </command:syntax>
<command:parameters> <command:parameters>
@@ -226,9 +386,9 @@
<dev:defaultValue>None</dev:defaultValue> <dev:defaultValue>None</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none"> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none">
<maml:name>ExportAllTests</maml:name> <maml:name>ExportNestedTables</maml:name>
<maml:description> <maml:description>
<maml:para>Switch to export all test results.</maml:para> <maml:para>Switch to export all test results. When specified, all test results are exported to the specified path.</maml:para>
</maml:description> </maml:description>
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue> <command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
<dev:type> <dev:type>
@@ -249,7 +409,7 @@
</dev:type> </dev:type>
<dev:defaultValue>None</dev:defaultValue> <dev:defaultValue>None</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>ExportOriginalTests</maml:name> <maml:name>ExportOriginalTests</maml:name>
<maml:description> <maml:description>
<maml:para>Switch to export the original audit results to a CSV file.</maml:para> <maml:para>Switch to export the original audit results to a CSV file.</maml:para>
@@ -273,11 +433,67 @@
</dev:type> </dev:type>
<dev:defaultValue>False</dev:defaultValue> <dev:defaultValue>False</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>Prefix</maml:name>
<maml:description>
<maml:para>Add Prefix to filename after date when outputting to excel or csv. Validate that the count of letters in the prefix is less than 5.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>Corp</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi">
<maml:name>WhatIf</maml:name>
<maml:description>
<maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
<dev:type>
<maml:name>SwitchParameter</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf">
<maml:name>Confirm</maml:name>
<maml:description>
<maml:para>Prompts you for confirmation before running the cmdlet.</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
<dev:type>
<maml:name>SwitchParameter</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="proga">
<maml:name>ProgressAction</maml:name>
<maml:description>
<maml:para>{{ Fill ProgressAction Description }}</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">ActionPreference</command:parameterValue>
<dev:type>
<maml:name>ActionPreference</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
</command:parameters> </command:parameters>
<command:inputTypes> <command:inputTypes>
<command:inputType> <command:inputType>
<dev:type> <dev:type>
<maml:name>[CISAuditResult[]], [string]</maml:name> <maml:name>[CISAuditResult[]] - An array of CISAuditResult objects.</maml:name>
</dev:type>
<maml:description>
<maml:para></maml:para>
</maml:description>
</command:inputType>
<command:inputType>
<dev:type>
<maml:name>[string] - A path to a CSV file.</maml:name>
</dev:type> </dev:type>
<maml:description> <maml:description>
<maml:para></maml:para> <maml:para></maml:para>
@@ -287,7 +503,7 @@
<command:returnValues> <command:returnValues>
<command:returnValue> <command:returnValue>
<dev:type> <dev:type>
<maml:name>[PSCustomObject]</maml:name> <maml:name>[PSCustomObject] - A custom object containing the path to the zip file and its hash.</maml:name>
</dev:type> </dev:type>
<maml:description> <maml:description>
<maml:para></maml:para> <maml:para></maml:para>
@@ -382,6 +598,18 @@
</dev:type> </dev:type>
<dev:defaultValue>False</dev:defaultValue> <dev:defaultValue>False</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="proga">
<maml:name>ProgressAction</maml:name>
<maml:description>
<maml:para>{{ Fill ProgressAction Description }}</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">ActionPreference</command:parameterValue>
<dev:type>
<maml:name>ActionPreference</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
</command:syntaxItem> </command:syntaxItem>
</command:syntax> </command:syntax>
<command:parameters> <command:parameters>
@@ -397,6 +625,18 @@
</dev:type> </dev:type>
<dev:defaultValue>False</dev:defaultValue> <dev:defaultValue>False</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="proga">
<maml:name>ProgressAction</maml:name>
<maml:description>
<maml:para>{{ Fill ProgressAction Description }}</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">ActionPreference</command:parameterValue>
<dev:type>
<maml:name>ActionPreference</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
</command:parameters> </command:parameters>
<command:inputTypes> <command:inputTypes>
<command:inputType> <command:inputType>
@@ -492,6 +732,18 @@
</dev:type> </dev:type>
<dev:defaultValue>False</dev:defaultValue> <dev:defaultValue>False</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="proga">
<maml:name>ProgressAction</maml:name>
<maml:description>
<maml:para>{{ Fill ProgressAction Description }}</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">ActionPreference</command:parameterValue>
<dev:type>
<maml:name>ActionPreference</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
</command:syntaxItem> </command:syntaxItem>
</command:syntax> </command:syntax>
<command:parameters> <command:parameters>
@@ -519,6 +771,18 @@
</dev:type> </dev:type>
<dev:defaultValue>False</dev:defaultValue> <dev:defaultValue>False</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="proga">
<maml:name>ProgressAction</maml:name>
<maml:description>
<maml:para>{{ Fill ProgressAction Description }}</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">ActionPreference</command:parameterValue>
<dev:type>
<maml:name>ActionPreference</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
</command:parameters> </command:parameters>
<command:inputTypes /> <command:inputTypes />
<command:returnValues> <command:returnValues>
@@ -718,6 +982,18 @@ Retrieves the MFA status for the specified user with the UPN "example@domain.com
</dev:type> </dev:type>
<dev:defaultValue>False</dev:defaultValue> <dev:defaultValue>False</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="proga">
<maml:name>ProgressAction</maml:name>
<maml:description>
<maml:para>{{ Fill ProgressAction Description }}</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">ActionPreference</command:parameterValue>
<dev:type>
<maml:name>ActionPreference</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
</command:syntaxItem> </command:syntaxItem>
</command:syntax> </command:syntax>
<command:parameters> <command:parameters>
@@ -805,6 +1081,18 @@ Retrieves the MFA status for the specified user with the UPN "example@domain.com
</dev:type> </dev:type>
<dev:defaultValue>False</dev:defaultValue> <dev:defaultValue>False</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="proga">
<maml:name>ProgressAction</maml:name>
<maml:description>
<maml:para>{{ Fill ProgressAction Description }}</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">ActionPreference</command:parameterValue>
<dev:type>
<maml:name>ActionPreference</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
</command:parameters> </command:parameters>
<command:inputTypes /> <command:inputTypes />
<command:returnValues> <command:returnValues>
@@ -976,6 +1264,18 @@ Retrieves the MFA status for the specified user with the UPN "example@domain.com
</dev:type> </dev:type>
<dev:defaultValue>False</dev:defaultValue> <dev:defaultValue>False</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>AuthParams</maml:name>
<maml:description>
<maml:para>Specifies an authentication object containing parameters for application-based authentication. If provided, this will be used for connecting to services.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">CISAuthenticationParameters</command:parameterValue>
<dev:type>
<maml:name>CISAuthenticationParameters</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi">
<maml:name>WhatIf</maml:name> <maml:name>WhatIf</maml:name>
<maml:description> <maml:description>
@@ -998,6 +1298,18 @@ Retrieves the MFA status for the specified user with the UPN "example@domain.com
</dev:type> </dev:type>
<dev:defaultValue>False</dev:defaultValue> <dev:defaultValue>False</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="proga">
<maml:name>ProgressAction</maml:name>
<maml:description>
<maml:para>{{ Fill ProgressAction Description }}</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">ActionPreference</command:parameterValue>
<dev:type>
<maml:name>ActionPreference</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
</command:syntaxItem> </command:syntaxItem>
<command:syntaxItem> <command:syntaxItem>
<maml:name>Invoke-M365SecurityAudit</maml:name> <maml:name>Invoke-M365SecurityAudit</maml:name>
@@ -1104,6 +1416,18 @@ Retrieves the MFA status for the specified user with the UPN "example@domain.com
</dev:type> </dev:type>
<dev:defaultValue>False</dev:defaultValue> <dev:defaultValue>False</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>AuthParams</maml:name>
<maml:description>
<maml:para>Specifies an authentication object containing parameters for application-based authentication. If provided, this will be used for connecting to services.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">CISAuthenticationParameters</command:parameterValue>
<dev:type>
<maml:name>CISAuthenticationParameters</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi">
<maml:name>WhatIf</maml:name> <maml:name>WhatIf</maml:name>
<maml:description> <maml:description>
@@ -1126,6 +1450,18 @@ Retrieves the MFA status for the specified user with the UPN "example@domain.com
</dev:type> </dev:type>
<dev:defaultValue>False</dev:defaultValue> <dev:defaultValue>False</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="proga">
<maml:name>ProgressAction</maml:name>
<maml:description>
<maml:para>{{ Fill ProgressAction Description }}</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">ActionPreference</command:parameterValue>
<dev:type>
<maml:name>ActionPreference</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
</command:syntaxItem> </command:syntaxItem>
<command:syntaxItem> <command:syntaxItem>
<maml:name>Invoke-M365SecurityAudit</maml:name> <maml:name>Invoke-M365SecurityAudit</maml:name>
@@ -1232,6 +1568,18 @@ Retrieves the MFA status for the specified user with the UPN "example@domain.com
</dev:type> </dev:type>
<dev:defaultValue>False</dev:defaultValue> <dev:defaultValue>False</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>AuthParams</maml:name>
<maml:description>
<maml:para>Specifies an authentication object containing parameters for application-based authentication. If provided, this will be used for connecting to services.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">CISAuthenticationParameters</command:parameterValue>
<dev:type>
<maml:name>CISAuthenticationParameters</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi">
<maml:name>WhatIf</maml:name> <maml:name>WhatIf</maml:name>
<maml:description> <maml:description>
@@ -1254,6 +1602,18 @@ Retrieves the MFA status for the specified user with the UPN "example@domain.com
</dev:type> </dev:type>
<dev:defaultValue>False</dev:defaultValue> <dev:defaultValue>False</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="proga">
<maml:name>ProgressAction</maml:name>
<maml:description>
<maml:para>{{ Fill ProgressAction Description }}</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">ActionPreference</command:parameterValue>
<dev:type>
<maml:name>ActionPreference</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
</command:syntaxItem> </command:syntaxItem>
<command:syntaxItem> <command:syntaxItem>
<maml:name>Invoke-M365SecurityAudit</maml:name> <maml:name>Invoke-M365SecurityAudit</maml:name>
@@ -1360,6 +1720,18 @@ Retrieves the MFA status for the specified user with the UPN "example@domain.com
</dev:type> </dev:type>
<dev:defaultValue>False</dev:defaultValue> <dev:defaultValue>False</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>AuthParams</maml:name>
<maml:description>
<maml:para>Specifies an authentication object containing parameters for application-based authentication. If provided, this will be used for connecting to services.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">CISAuthenticationParameters</command:parameterValue>
<dev:type>
<maml:name>CISAuthenticationParameters</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi">
<maml:name>WhatIf</maml:name> <maml:name>WhatIf</maml:name>
<maml:description> <maml:description>
@@ -1382,6 +1754,18 @@ Retrieves the MFA status for the specified user with the UPN "example@domain.com
</dev:type> </dev:type>
<dev:defaultValue>False</dev:defaultValue> <dev:defaultValue>False</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="proga">
<maml:name>ProgressAction</maml:name>
<maml:description>
<maml:para>{{ Fill ProgressAction Description }}</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">ActionPreference</command:parameterValue>
<dev:type>
<maml:name>ActionPreference</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
</command:syntaxItem> </command:syntaxItem>
<command:syntaxItem> <command:syntaxItem>
<maml:name>Invoke-M365SecurityAudit</maml:name> <maml:name>Invoke-M365SecurityAudit</maml:name>
@@ -1489,6 +1873,18 @@ Retrieves the MFA status for the specified user with the UPN "example@domain.com
</dev:type> </dev:type>
<dev:defaultValue>False</dev:defaultValue> <dev:defaultValue>False</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>AuthParams</maml:name>
<maml:description>
<maml:para>Specifies an authentication object containing parameters for application-based authentication. If provided, this will be used for connecting to services.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">CISAuthenticationParameters</command:parameterValue>
<dev:type>
<maml:name>CISAuthenticationParameters</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi">
<maml:name>WhatIf</maml:name> <maml:name>WhatIf</maml:name>
<maml:description> <maml:description>
@@ -1511,6 +1907,18 @@ Retrieves the MFA status for the specified user with the UPN "example@domain.com
</dev:type> </dev:type>
<dev:defaultValue>False</dev:defaultValue> <dev:defaultValue>False</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="proga">
<maml:name>ProgressAction</maml:name>
<maml:description>
<maml:para>{{ Fill ProgressAction Description }}</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">ActionPreference</command:parameterValue>
<dev:type>
<maml:name>ActionPreference</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
</command:syntaxItem> </command:syntaxItem>
<command:syntaxItem> <command:syntaxItem>
<maml:name>Invoke-M365SecurityAudit</maml:name> <maml:name>Invoke-M365SecurityAudit</maml:name>
@@ -1618,6 +2026,18 @@ Retrieves the MFA status for the specified user with the UPN "example@domain.com
</dev:type> </dev:type>
<dev:defaultValue>False</dev:defaultValue> <dev:defaultValue>False</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>AuthParams</maml:name>
<maml:description>
<maml:para>Specifies an authentication object containing parameters for application-based authentication. If provided, this will be used for connecting to services.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">CISAuthenticationParameters</command:parameterValue>
<dev:type>
<maml:name>CISAuthenticationParameters</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi">
<maml:name>WhatIf</maml:name> <maml:name>WhatIf</maml:name>
<maml:description> <maml:description>
@@ -1640,6 +2060,18 @@ Retrieves the MFA status for the specified user with the UPN "example@domain.com
</dev:type> </dev:type>
<dev:defaultValue>False</dev:defaultValue> <dev:defaultValue>False</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="proga">
<maml:name>ProgressAction</maml:name>
<maml:description>
<maml:para>{{ Fill ProgressAction Description }}</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">ActionPreference</command:parameterValue>
<dev:type>
<maml:name>ActionPreference</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
</command:syntaxItem> </command:syntaxItem>
</command:syntax> </command:syntax>
<command:parameters> <command:parameters>
@@ -1823,6 +2255,18 @@ Retrieves the MFA status for the specified user with the UPN "example@domain.com
</dev:type> </dev:type>
<dev:defaultValue>False</dev:defaultValue> <dev:defaultValue>False</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>AuthParams</maml:name>
<maml:description>
<maml:para>Specifies an authentication object containing parameters for application-based authentication. If provided, this will be used for connecting to services.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">CISAuthenticationParameters</command:parameterValue>
<dev:type>
<maml:name>CISAuthenticationParameters</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi">
<maml:name>WhatIf</maml:name> <maml:name>WhatIf</maml:name>
<maml:description> <maml:description>
@@ -1847,6 +2291,18 @@ Retrieves the MFA status for the specified user with the UPN "example@domain.com
</dev:type> </dev:type>
<dev:defaultValue>False</dev:defaultValue> <dev:defaultValue>False</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="proga">
<maml:name>ProgressAction</maml:name>
<maml:description>
<maml:para>{{ Fill ProgressAction Description }}</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">ActionPreference</command:parameterValue>
<dev:type>
<maml:name>ActionPreference</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
</command:parameters> </command:parameters>
<command:inputTypes> <command:inputTypes>
<command:inputType> <command:inputType>
@@ -1951,6 +2407,218 @@ PS&gt; $auditResults | Export-Csv -Path "auditResults.csv" -NoTypeInformation</d
</maml:navigationLink> </maml:navigationLink>
</command:relatedLinks> </command:relatedLinks>
</command:command> </command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp">
<command:details>
<command:name>New-M365SecurityAuditAuthObject</command:name>
<command:verb>New</command:verb>
<command:noun>M365SecurityAuditAuthObject</command:noun>
<maml:description>
<maml:para>Creates a new CISAuthenticationParameters object for Microsoft 365 authentication.</maml:para>
</maml:description>
</command:details>
<maml:description>
<maml:para>The New-M365SecurityAuditAuthObject function constructs a new CISAuthenticationParameters object containing the necessary credentials and URLs for authenticating to various Microsoft 365 services. It validates input parameters to ensure they conform to expected formats and length requirements. An app registration in Azure AD with the required permissions to EXO, SPO, MSTeams and MgGraph is needed.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>New-M365SecurityAuditAuthObject</maml:name>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none">
<maml:name>ClientCertThumbPrint</maml:name>
<maml:description>
<maml:para>The thumbprint of the client certificate used for authentication. It must be a 40-character hexadecimal string. This certificate is used to authenticate the application in Azure AD.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="2" aliases="none">
<maml:name>ClientId</maml:name>
<maml:description>
<maml:para>The Client ID (Application ID) of the Azure AD application. It must be a valid GUID format.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="3" aliases="none">
<maml:name>TenantId</maml:name>
<maml:description>
<maml:para>The Tenant ID of the Azure AD directory. It must be a valid GUID format representing your Microsoft 365 tenant.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="4" aliases="none">
<maml:name>OnMicrosoftUrl</maml:name>
<maml:description>
<maml:para>The URL of your onmicrosoft.com domain. It should be in the format 'example.onmicrosoft.com'.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="5" aliases="none">
<maml:name>SpAdminUrl</maml:name>
<maml:description>
<maml:para>The SharePoint admin URL, which should end with '-admin.sharepoint.com'. This URL is used for connecting to SharePoint Online.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="proga">
<maml:name>ProgressAction</maml:name>
<maml:description>
<maml:para>{{ Fill ProgressAction Description }}</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">ActionPreference</command:parameterValue>
<dev:type>
<maml:name>ActionPreference</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none">
<maml:name>ClientCertThumbPrint</maml:name>
<maml:description>
<maml:para>The thumbprint of the client certificate used for authentication. It must be a 40-character hexadecimal string. This certificate is used to authenticate the application in Azure AD.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="2" aliases="none">
<maml:name>ClientId</maml:name>
<maml:description>
<maml:para>The Client ID (Application ID) of the Azure AD application. It must be a valid GUID format.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="3" aliases="none">
<maml:name>TenantId</maml:name>
<maml:description>
<maml:para>The Tenant ID of the Azure AD directory. It must be a valid GUID format representing your Microsoft 365 tenant.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="4" aliases="none">
<maml:name>OnMicrosoftUrl</maml:name>
<maml:description>
<maml:para>The URL of your onmicrosoft.com domain. It should be in the format 'example.onmicrosoft.com'.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="5" aliases="none">
<maml:name>SpAdminUrl</maml:name>
<maml:description>
<maml:para>The SharePoint admin URL, which should end with '-admin.sharepoint.com'. This URL is used for connecting to SharePoint Online.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="proga">
<maml:name>ProgressAction</maml:name>
<maml:description>
<maml:para>{{ Fill ProgressAction Description }}</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">ActionPreference</command:parameterValue>
<dev:type>
<maml:name>ActionPreference</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
</command:parameters>
<command:inputTypes>
<command:inputType>
<dev:type>
<maml:name>None. You cannot pipe objects to this function.</maml:name>
</dev:type>
<maml:description>
<maml:para></maml:para>
</maml:description>
</command:inputType>
</command:inputTypes>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>CISAuthenticationParameters</maml:name>
</dev:type>
<maml:description>
<maml:para></maml:para>
</maml:description>
</command:returnValue>
<command:returnValue>
<dev:type>
<maml:name>The function returns an instance of the CISAuthenticationParameters class containing the authentication details.</maml:name>
</dev:type>
<maml:description>
<maml:para></maml:para>
</maml:description>
</command:returnValue>
</command:returnValues>
<maml:alertSet>
<maml:alert>
<maml:para>Requires PowerShell 7.0 or later.</maml:para>
</maml:alert>
</maml:alertSet>
<command:examples>
<command:example>
<maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
<dev:code>$authParams = New-M365SecurityAuditAuthObject -ClientCertThumbPrint "ABCDEF1234567890ABCDEF1234567890ABCDEF12" `
-ClientId "12345678-1234-1234-1234-123456789012" `
-TenantId "12345678-1234-1234-1234-123456789012" `
-OnMicrosoftUrl "yourcompany.onmicrosoft.com" `
-SpAdminUrl "https://yourcompany-admin.sharepoint.com"
Creates a new CISAuthenticationParameters object with the specified credentials and URLs, validating each parameter's format and length.</dev:code>
<dev:remarks>
<maml:para></maml:para>
</dev:remarks>
</command:example>
</command:examples>
<command:relatedLinks />
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp">
<command:details> <command:details>
<command:name>Remove-RowsWithEmptyCSVStatus</command:name> <command:name>Remove-RowsWithEmptyCSVStatus</command:name>
@@ -1990,6 +2658,18 @@ PS&gt; $auditResults | Export-Csv -Path "auditResults.csv" -NoTypeInformation</d
</dev:type> </dev:type>
<dev:defaultValue>None</dev:defaultValue> <dev:defaultValue>None</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="proga">
<maml:name>ProgressAction</maml:name>
<maml:description>
<maml:para>{{ Fill ProgressAction Description }}</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">ActionPreference</command:parameterValue>
<dev:type>
<maml:name>ActionPreference</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
</command:syntaxItem> </command:syntaxItem>
</command:syntax> </command:syntax>
<command:parameters> <command:parameters>
@@ -2017,6 +2697,18 @@ PS&gt; $auditResults | Export-Csv -Path "auditResults.csv" -NoTypeInformation</d
</dev:type> </dev:type>
<dev:defaultValue>None</dev:defaultValue> <dev:defaultValue>None</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="proga">
<maml:name>ProgressAction</maml:name>
<maml:description>
<maml:para>{{ Fill ProgressAction Description }}</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">ActionPreference</command:parameterValue>
<dev:type>
<maml:name>ActionPreference</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
</command:parameters> </command:parameters>
<command:inputTypes /> <command:inputTypes />
<command:returnValues /> <command:returnValues />
@@ -2088,6 +2780,18 @@ This command imports data from the "Sheet1" worksheet in the "Report.xlsx" file,
</dev:type> </dev:type>
<dev:defaultValue>None</dev:defaultValue> <dev:defaultValue>None</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="proga">
<maml:name>ProgressAction</maml:name>
<maml:description>
<maml:para>{{ Fill ProgressAction Description }}</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">ActionPreference</command:parameterValue>
<dev:type>
<maml:name>ActionPreference</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
</command:syntaxItem> </command:syntaxItem>
</command:syntax> </command:syntax>
<command:parameters> <command:parameters>
@@ -2127,6 +2831,18 @@ This command imports data from the "Sheet1" worksheet in the "Report.xlsx" file,
</dev:type> </dev:type>
<dev:defaultValue>None</dev:defaultValue> <dev:defaultValue>None</dev:defaultValue>
</command:parameter> </command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="proga">
<maml:name>ProgressAction</maml:name>
<maml:description>
<maml:para>{{ Fill ProgressAction Description }}</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">ActionPreference</command:parameterValue>
<dev:type>
<maml:name>ActionPreference</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
</command:parameters> </command:parameters>
<command:inputTypes> <command:inputTypes>
<command:inputType> <command:inputType>

View File

@@ -30,9 +30,11 @@ Optional Subtopics
EXAMPLES EXAMPLES
# Example 1: Performing a security audit based on CIS benchmarks # Example 1: Performing a security audit based on CIS benchmarks
$auditResults = Invoke-M365SecurityAudit -TenantAdminUrl "https://contoso-admin.sharepoint.com" $auditResults = Invoke-M365SecurityAudit -TenantAdminUrl "https://contoso-admin.sharepoint.com"
$auditResults = Invoke-M365SecurityAudit -TenantAdminUrl "https://contoso-admin.sharepoint.com" -DomainName "contoso.com" -ApprovedCloudStorageProviders "DropBox" -ApprovedFederatedDomains "northwind.com"
# Example 2: Exporting a security audit table to a CSV file # Example 2: Exporting a security audit and it's nested tables to zipped CSV files
Export-M365SecurityAuditTable -ExportAllTests -AuditResults $auditResults -ExportPath "C:\temp" -ExportOriginalTests Export-M365SecurityAuditTable -AuditResults $auditResults -ExportPath "C:\temp" -ExportOriginalTests -ExportAllTests
# Output Ex: 2024.07.07_14.55.55_M365FoundationsAudit_368B2E2F.zip
# Example 3: Retrieving licenses for users in administrative roles # Example 3: Retrieving licenses for users in administrative roles
Get-AdminRoleUserLicense Get-AdminRoleUserLicense
@@ -49,6 +51,14 @@ EXAMPLES
# Example 7: Granting Microsoft Graph permissions to the auditor # Example 7: Granting Microsoft Graph permissions to the auditor
Grant-M365SecurityAuditConsent -UserPrincipalNameForConsent 'user@example.com' Grant-M365SecurityAuditConsent -UserPrincipalNameForConsent 'user@example.com'
# Example 8: (PowerShell 7.x Only) Creating a new authentication object for the security audit for app-based authentication.
$authParams = New-M365SecurityAuditAuthObject -ClientCertThumbPrint "ABCDEF1234567890ABCDEF1234567890ABCDEF12" `
-ClientId "12345678-1234-1234-1234-123456789012" `
-TenantId "12345678-1234-1234-1234-123456789012" `
-OnMicrosoftUrl "yourcompany.onmicrosoft.com" `
-SpAdminUrl "https://yourcompany-admin.sharepoint.com"
Invoke-M365SecurityAudit -AuthParams $authParams -TenantAdminUrl "https://yourcompany-admin.sharepoint.com"
NOTE NOTE
Ensure that you have the necessary permissions and administrative roles in Ensure that you have the necessary permissions and administrative roles in
your Microsoft 365 environment to run these cmdlets. Proper configuration your Microsoft 365 environment to run these cmdlets. Proper configuration

View File

@@ -2,7 +2,7 @@
1,Test-AdministrativeAccountCompliance.ps1,1.1.1,Ensure Administrative accounts are separate and cloud-only,E3,L1,5.4,Restrict Administrator Privileges to Dedicated Administrator Accounts,TRUE,TRUE,TRUE,FALSE,Microsoft Graph 1,Test-AdministrativeAccountCompliance.ps1,1.1.1,Ensure Administrative accounts are separate and cloud-only,E3,L1,5.4,Restrict Administrator Privileges to Dedicated Administrator Accounts,TRUE,TRUE,TRUE,FALSE,Microsoft Graph
2,Test-GlobalAdminsCount.ps1,1.1.3,Ensure that between two and four global admins are designated,E3,L1,5.1,Establish and Maintain an Inventory of Accounts,TRUE,TRUE,TRUE,TRUE,Microsoft Graph 2,Test-GlobalAdminsCount.ps1,1.1.3,Ensure that between two and four global admins are designated,E3,L1,5.1,Establish and Maintain an Inventory of Accounts,TRUE,TRUE,TRUE,TRUE,Microsoft Graph
3,Test-ManagedApprovedPublicGroups.ps1,1.2.1,Ensure that only organizationally managed/approved public groups exist,E3,L2,3.3,Configure Data Access Control Lists,TRUE,TRUE,TRUE,TRUE,Microsoft Graph 3,Test-ManagedApprovedPublicGroups.ps1,1.2.1,Ensure that only organizationally managed/approved public groups exist,E3,L2,3.3,Configure Data Access Control Lists,TRUE,TRUE,TRUE,TRUE,Microsoft Graph
4,Test-BlockSharedMailboxSignIn.ps1,1.2.2,Ensure sign-in to shared mailboxes is blocked,E3,L1,0,Explicitly Not Mapped,FALSE,FALSE,FALSE,TRUE,AzureAD | EXO 4,Test-BlockSharedMailboxSignIn.ps1,1.2.2,Ensure sign-in to shared mailboxes is blocked,E3,L1,0,Explicitly Not Mapped,FALSE,FALSE,FALSE,TRUE,EXO | Microsoft Graph
5,Test-PasswordNeverExpirePolicy.ps1,1.3.1,Ensure the 'Password expiration policy' is set to 'Set passwords to never expire',E3,L1,5.2,Use Unique Passwords,TRUE,TRUE,TRUE,TRUE,Microsoft Graph 5,Test-PasswordNeverExpirePolicy.ps1,1.3.1,Ensure the 'Password expiration policy' is set to 'Set passwords to never expire',E3,L1,5.2,Use Unique Passwords,TRUE,TRUE,TRUE,TRUE,Microsoft Graph
6,Test-ExternalSharingCalendars.ps1,1.3.3,Ensure 'External sharing' of calendars is not available,E3,L2,4.8,Uninstall or Disable Unnecessary Services on Enterprise Assets and Software,FALSE,TRUE,TRUE,TRUE,EXO 6,Test-ExternalSharingCalendars.ps1,1.3.3,Ensure 'External sharing' of calendars is not available,E3,L2,4.8,Uninstall or Disable Unnecessary Services on Enterprise Assets and Software,FALSE,TRUE,TRUE,TRUE,EXO
7,Test-CustomerLockbox.ps1,1.3.6,Ensure the customer lockbox feature is enabled,E5,L2,0,Explicitly Not Mapped,FALSE,FALSE,FALSE,TRUE,EXO 7,Test-CustomerLockbox.ps1,1.3.6,Ensure the customer lockbox feature is enabled,E5,L2,0,Explicitly Not Mapped,FALSE,FALSE,FALSE,TRUE,EXO
1 Index TestFileName Rec RecDescription ELevel ProfileLevel CISControl CISDescription IG1 IG2 IG3 Automated Connection
2 1 Test-AdministrativeAccountCompliance.ps1 1.1.1 Ensure Administrative accounts are separate and cloud-only E3 L1 5.4 Restrict Administrator Privileges to Dedicated Administrator Accounts TRUE TRUE TRUE FALSE Microsoft Graph
3 2 Test-GlobalAdminsCount.ps1 1.1.3 Ensure that between two and four global admins are designated E3 L1 5.1 Establish and Maintain an Inventory of Accounts TRUE TRUE TRUE TRUE Microsoft Graph
4 3 Test-ManagedApprovedPublicGroups.ps1 1.2.1 Ensure that only organizationally managed/approved public groups exist E3 L2 3.3 Configure Data Access Control Lists TRUE TRUE TRUE TRUE Microsoft Graph
5 4 Test-BlockSharedMailboxSignIn.ps1 1.2.2 Ensure sign-in to shared mailboxes is blocked E3 L1 0 Explicitly Not Mapped FALSE FALSE FALSE TRUE AzureAD | EXO EXO | Microsoft Graph
6 5 Test-PasswordNeverExpirePolicy.ps1 1.3.1 Ensure the 'Password expiration policy' is set to 'Set passwords to never expire' E3 L1 5.2 Use Unique Passwords TRUE TRUE TRUE TRUE Microsoft Graph
7 6 Test-ExternalSharingCalendars.ps1 1.3.3 Ensure 'External sharing' of calendars is not available E3 L2 4.8 Uninstall or Disable Unnecessary Services on Enterprise Assets and Software FALSE TRUE TRUE TRUE EXO
8 7 Test-CustomerLockbox.ps1 1.3.6 Ensure the customer lockbox feature is enabled E5 L2 0 Explicitly Not Mapped FALSE FALSE FALSE TRUE EXO

View File

@@ -1,7 +1,6 @@
function Test-AdministrativeAccountCompliance { function Test-AdministrativeAccountCompliance {
[CmdletBinding()] [CmdletBinding()]
param () param ()
begin { begin {
# The following conditions are checked: # The following conditions are checked:
# Condition A: The administrative account is cloud-only (not synced). # Condition A: The administrative account is cloud-only (not synced).
@@ -11,16 +10,12 @@ function Test-AdministrativeAccountCompliance {
$recnum = "1.1.1" $recnum = "1.1.1"
Write-Verbose "Starting Test-AdministrativeAccountCompliance with Rec: $recnum" Write-Verbose "Starting Test-AdministrativeAccountCompliance with Rec: $recnum"
} }
process { process {
try { try {
# Retrieve admin roles, assignments, and user details including licenses # Retrieve admin roles, assignments, and user details including licenses
Write-Verbose "Retrieving admin roles, assignments, and user details including licenses" Write-Verbose "Retrieving admin roles, assignments, and user details including licenses"
$adminRoleAssignments = Get-CISMgOutput -Rec $recnum $adminRoleAssignments = Get-CISMgOutput -Rec $recnum
$adminRoleUsers = @() $adminRoleUsers = @()
foreach ($roleName in $adminRoleAssignments.Keys) { foreach ($roleName in $adminRoleAssignments.Keys) {
$assignments = $adminRoleAssignments[$roleName] $assignments = $adminRoleAssignments[$roleName]
foreach ($assignment in $assignments) { foreach ($assignment in $assignments) {
@@ -29,21 +24,16 @@ function Test-AdministrativeAccountCompliance {
$userPrincipalName = $userDetails.UserPrincipalName $userPrincipalName = $userDetails.UserPrincipalName
$licenses = $assignment.Licenses $licenses = $assignment.Licenses
$licenseString = if ($licenses) { ($licenses.SkuPartNumber -join '|') } else { "No Licenses Found" } $licenseString = if ($licenses) { ($licenses.SkuPartNumber -join '|') } else { "No Licenses Found" }
# Condition A: Check if the account is cloud-only # Condition A: Check if the account is cloud-only
$cloudOnlyStatus = if ($userDetails.OnPremisesSyncEnabled) { "Fail" } else { "Pass" } $cloudOnlyStatus = if ($userDetails.OnPremisesSyncEnabled) { "Fail" } else { "Pass" }
# Condition B: Check if the account has valid licenses # Condition B: Check if the account has valid licenses
$hasValidLicense = $licenses.SkuPartNumber | ForEach-Object { $validLicenses -contains $_ } $hasValidLicense = $licenses.SkuPartNumber | ForEach-Object { $validLicenses -contains $_ }
$validLicensesStatus = if ($hasValidLicense) { "Pass" } else { "Fail" } $validLicensesStatus = if ($hasValidLicense) { "Pass" } else { "Fail" }
# Condition C: Check if the account has no other licenses # Condition C: Check if the account has no other licenses
$hasInvalidLicense = $licenses.SkuPartNumber | ForEach-Object { $validLicenses -notcontains $_ } $hasInvalidLicense = $licenses.SkuPartNumber | ForEach-Object { $validLicenses -notcontains $_ }
$invalidLicenses = $licenses.SkuPartNumber | Where-Object { $validLicenses -notcontains $_ } $invalidLicenses = $licenses.SkuPartNumber | Where-Object { $validLicenses -notcontains $_ }
$applicationAssignmentStatus = if ($hasInvalidLicense) { "Fail" } else { "Pass" } $applicationAssignmentStatus = if ($hasInvalidLicense) { "Fail" } else { "Pass" }
Write-Verbose "User: $userPrincipalName, Cloud-Only: $cloudOnlyStatus, Valid Licenses: $validLicensesStatus, Invalid Licenses: $($invalidLicenses -join ', ')" Write-Verbose "User: $userPrincipalName, Cloud-Only: $cloudOnlyStatus, Valid Licenses: $validLicensesStatus, Invalid Licenses: $($invalidLicenses -join ', ')"
# Collect user information # Collect user information
$adminRoleUsers += [PSCustomObject]@{ $adminRoleUsers += [PSCustomObject]@{
UserName = $userPrincipalName UserName = $userPrincipalName
@@ -57,17 +47,14 @@ function Test-AdministrativeAccountCompliance {
} }
} }
} }
# Group admin role users by UserName and collect unique roles and licenses # Group admin role users by UserName and collect unique roles and licenses
Write-Verbose "Grouping admin role users by UserName" Write-Verbose "Grouping admin role users by UserName"
$uniqueAdminRoleUsers = $adminRoleUsers | Group-Object -Property UserName | ForEach-Object { $uniqueAdminRoleUsers = $adminRoleUsers | Group-Object -Property UserName | ForEach-Object {
$first = $_.Group | Select-Object -First 1 $first = $_.Group | Select-Object -First 1
$roles = ($_.Group.RoleName -join ', ') $roles = ($_.Group.RoleName -join ', ')
$licenses = (($_.Group | Select-Object -ExpandProperty Licenses) -join ',').Split(',') | Select-Object -Unique $licenses = (($_.Group | Select-Object -ExpandProperty Licenses) -join ',').Split(',') | Select-Object -Unique
$first | Select-Object UserName, UserId, HybridUser, @{Name = 'Roles'; Expression = { $roles } }, @{Name = 'Licenses'; Expression = { $licenses -join '|' } }, CloudOnlyStatus, ValidLicensesStatus, ApplicationAssignmentStatus $first | Select-Object UserName, UserId, HybridUser, @{Name = 'Roles'; Expression = { $roles } }, @{Name = 'Licenses'; Expression = { $licenses -join '|' } }, CloudOnlyStatus, ValidLicensesStatus, ApplicationAssignmentStatus
} }
# Identify non-compliant users based on conditions A, B, and C # Identify non-compliant users based on conditions A, B, and C
Write-Verbose "Identifying non-compliant users based on conditions" Write-Verbose "Identifying non-compliant users based on conditions"
$nonCompliantUsers = $uniqueAdminRoleUsers | Where-Object { $nonCompliantUsers = $uniqueAdminRoleUsers | Where-Object {
@@ -75,7 +62,6 @@ function Test-AdministrativeAccountCompliance {
$_.ValidLicensesStatus -eq "Fail" -or # Fails Condition B $_.ValidLicensesStatus -eq "Fail" -or # Fails Condition B
$_.ApplicationAssignmentStatus -eq "Fail" # Fails Condition C $_.ApplicationAssignmentStatus -eq "Fail" # Fails Condition C
} }
# Generate failure reasons # Generate failure reasons
Write-Verbose "Generating failure reasons for non-compliant users" Write-Verbose "Generating failure reasons for non-compliant users"
$failureReasons = $nonCompliantUsers | ForEach-Object { $failureReasons = $nonCompliantUsers | ForEach-Object {
@@ -88,13 +74,10 @@ function Test-AdministrativeAccountCompliance {
else { else {
"Compliant Accounts: $($uniqueAdminRoleUsers.Count)" "Compliant Accounts: $($uniqueAdminRoleUsers.Count)"
} }
$result = $nonCompliantUsers.Count -eq 0 $result = $nonCompliantUsers.Count -eq 0
$status = if ($result) { 'Pass' } else { 'Fail' } $status = if ($result) { 'Pass' } else { 'Fail' }
$details = if ($nonCompliantUsers) { "Username | Roles | Cloud-Only Status | EntraID P1/P2 License Status | Other Applications Assigned Status`n$failureReasons" } else { "N/A" } $details = if ($nonCompliantUsers) { "Username | Roles | Cloud-Only Status | EntraID P1/P2 License Status | Other Applications Assigned Status`n$failureReasons" } else { "N/A" }
Write-Verbose "Assessment completed. Result: $status" Write-Verbose "Assessment completed. Result: $status"
# Create the parameter splat # Create the parameter splat
$params = @{ $params = @{
Rec = $recnum Rec = $recnum
@@ -103,7 +86,6 @@ function Test-AdministrativeAccountCompliance {
Details = $details Details = $details
FailureReason = $failureReason FailureReason = $failureReason
} }
$auditResult = Initialize-CISAuditResult @params $auditResult = Initialize-CISAuditResult @params
} }
catch { catch {
@@ -111,7 +93,6 @@ function Test-AdministrativeAccountCompliance {
$auditResult = Get-TestError -LastError $LastError -recnum $recnum $auditResult = Get-TestError -LastError $LastError -recnum $recnum
} }
} }
end { end {
# Output the result # Output the result
return $auditResult return $auditResult

View File

@@ -215,7 +215,7 @@ function Test-AntiPhishingPolicy {
$auditResult = Initialize-CISAuditResult @params $auditResult = Initialize-CISAuditResult @params
} }
catch { catch {
Write-Error "An error occurred during the test: $_" Write-Error "An error occurred during the test $recnum`:: $_"
$auditResult = Get-TestError -LastError $_ -recnum $recnum $auditResult = Get-TestError -LastError $_ -recnum $recnum
} }
} }

View File

@@ -58,9 +58,9 @@ function Test-BlockSharedMailboxSignIn {
} }
) )
#> #>
$users = Get-CISAadOutput -Rec $recnum $users = Get-CISMgOutput -Rec $recnum
# Step: Retrieve details of shared mailboxes from Azure AD (Condition B: Pass/Fail) # Step: Retrieve details of shared mailboxes from Azure AD (Condition B: Pass/Fail)
$sharedMailboxDetails = $users | Where-Object {$_.objectid -in $objectids} $sharedMailboxDetails = $users | Where-Object {$_.id -in $objectids}
# Step: Identify enabled mailboxes (Condition B: Pass/Fail) # Step: Identify enabled mailboxes (Condition B: Pass/Fail)
$enabledMailboxes = $sharedMailboxDetails | Where-Object { $_.AccountEnabled } | ForEach-Object { $_.DisplayName } $enabledMailboxes = $sharedMailboxDetails | Where-Object { $_.AccountEnabled } | ForEach-Object { $_.DisplayName }
$allBlocked = $enabledMailboxes.Count -eq 0 $allBlocked = $enabledMailboxes.Count -eq 0

View File

@@ -5,17 +5,14 @@ function Test-DisallowInfectedFilesDownload {
# Aligned # Aligned
# Define your parameters here if needed # Define your parameters here if needed
) )
begin { begin {
# Dot source the class script if necessary # Dot source the class script if necessary
#. .\source\Classes\CISAuditResult.ps1 #. .\source\Classes\CISAuditResult.ps1
# Initialization code, if needed # Initialization code, if needed
$recnum = "7.3.1" $recnum = "7.3.1"
Write-Verbose "Running Test-DisallowInfectedFilesDownload for $recnum..."
} }
process { process {
try { try {
# 7.3.1 (L2) Ensure Office 365 SharePoint infected files are disallowed for download # 7.3.1 (L2) Ensure Office 365 SharePoint infected files are disallowed for download
# #
@@ -32,28 +29,30 @@ function Test-DisallowInfectedFilesDownload {
# - Condition A: The `DisallowInfectedFileDownload` setting is not set to `True`. # - Condition A: The `DisallowInfectedFileDownload` setting is not set to `True`.
# - Condition B: The setting does not prevent users from downloading infected files. # - Condition B: The setting does not prevent users from downloading infected files.
# - Condition C: Verification using the PowerShell command indicates that the setting is incorrectly configured. # - Condition C: Verification using the PowerShell command indicates that the setting is incorrectly configured.
# Retrieve the SharePoint tenant configuration # Retrieve the SharePoint tenant configuration
# $SPOTenantDisallowInfectedFileDownload Mock Object
<#
$SPOTenantDisallowInfectedFileDownload = [PSCustomObject]@{
DisallowInfectedFileDownload = $false
}
#>
$SPOTenantDisallowInfectedFileDownload = Get-CISSpoOutput -Rec $recnum $SPOTenantDisallowInfectedFileDownload = Get-CISSpoOutput -Rec $recnum
# Condition A: The `DisallowInfectedFileDownload` setting is set to `True` # Condition A: The `DisallowInfectedFileDownload` setting is set to `True`
$isDisallowInfectedFileDownloadEnabled = $SPOTenantDisallowInfectedFileDownload.DisallowInfectedFileDownload $isDisallowInfectedFileDownloadEnabled = $SPOTenantDisallowInfectedFileDownload.DisallowInfectedFileDownload
# Prepare failure reasons and details based on compliance # Prepare failure reasons and details based on compliance
$failureReasons = if (-not $isDisallowInfectedFileDownloadEnabled) { $failureReasons = if (-not $isDisallowInfectedFileDownloadEnabled) {
"Downloading infected files is not disallowed." # Condition B: The setting does not prevent users from downloading infected files "Downloading infected files is not disallowed. To ensure infected files cannot be downloaded, use the following command:`n" + ` # Condition B: The setting does not prevent users from downloading infected files
"Set-SPOTenant -DisallowInfectedFileDownload `$true"
} }
else { else {
"N/A" "N/A"
} }
$details = if ($isDisallowInfectedFileDownloadEnabled) { $details = if ($isDisallowInfectedFileDownloadEnabled) {
"DisallowInfectedFileDownload: True" # Condition C: Verification confirms the setting is correctly configured "DisallowInfectedFileDownload: True" # Condition C: Verification confirms the setting is correctly configured
} }
else { else {
"DisallowInfectedFileDownload: False" # Condition C: Verification indicates the setting is incorrectly configured "DisallowInfectedFileDownload: False" # Condition C: Verification indicates the setting is incorrectly configured
} }
# Create and populate the CISAuditResult object # Create and populate the CISAuditResult object
$params = @{ $params = @{
Rec = $recnum Rec = $recnum
@@ -69,7 +68,6 @@ function Test-DisallowInfectedFilesDownload {
$auditResult = Get-TestError -LastError $LastError -recnum $recnum $auditResult = Get-TestError -LastError $LastError -recnum $recnum
} }
} }
end { end {
# Return the audit result # Return the audit result
return $auditResult return $auditResult

View File

@@ -5,12 +5,14 @@ function Test-ExternalSharingCalendars {
# Aligned # Aligned
# Parameters can be added if needed # Parameters can be added if needed
) )
begin { begin {
# Dot source the class script if necessary # Dot source the class script if necessary
#. .\source\Classes\CISAuditResult.ps1 #. .\source\Classes\CISAuditResult.ps1
# Initialization code, if needed # Initialization code, if needed
$recnum = "1.3.3" $recnum = "1.3.3"
Write-Verbose "Running Test-ExternalSharingCalendars for $recnum..."
# Conditions for 1.3.3 (L2) Ensure 'External sharing' of calendars is not available (Automated) # Conditions for 1.3.3 (L2) Ensure 'External sharing' of calendars is not available (Automated)
# #
# Validate test for a pass: # Validate test for a pass:
@@ -25,19 +27,12 @@ function Test-ExternalSharingCalendars {
# - Condition A: In the Microsoft 365 admin center, external calendar sharing is enabled. # - Condition A: In the Microsoft 365 admin center, external calendar sharing is enabled.
# - Condition B: Using the Exchange Online PowerShell Module, the `OrganizationConfig` property `ExternalSharingEnabled` is set to `True`. # - Condition B: Using the Exchange Online PowerShell Module, the `OrganizationConfig` property `ExternalSharingEnabled` is set to `True`.
} }
process { process {
try { try {
# Step: Retrieve sharing policies related to calendar sharing # Step: Retrieve sharing policies related to calendar sharing
# $sharingPolicies Mock Object
<#
$sharingPolicies = [PSCustomObject]@{
Name = "Default Sharing Policy"
Domains = @("Anonymous:CalendarSharingFreeBusySimple")
Enabled = $true
Default = $true
}
#>
$sharingPolicies = Get-CISExoOutput -Rec $recnum $sharingPolicies = Get-CISExoOutput -Rec $recnum
# Step (Condition A & B: Pass/Fail): Check if calendar sharing is disabled in all applicable policies # Step (Condition A & B: Pass/Fail): Check if calendar sharing is disabled in all applicable policies
$isExternalSharingDisabled = $true $isExternalSharingDisabled = $true
$sharingPolicyDetails = @() $sharingPolicyDetails = @()
@@ -47,43 +42,47 @@ function Test-ExternalSharingCalendars {
$sharingPolicyDetails += "$($policy.Name): Enabled" $sharingPolicyDetails += "$($policy.Name): Enabled"
} }
} }
# Retrieve calendars with publishing enabled (from 1.3.3b) $failureRemediation = @'
# $calendarDetails Mock Object # Get all mailboxes
<# $mailboxes = Get-Mailbox -ResultSize Unlimited
$calendarDetails = @(
[PSCustomObject]@{ # Initialize a hashtable to store calendar folder names
Calendar = "SMBuser1@domain.com" $calendarFolders = @{}
URL = "https://example.com/calendar/smbuser1" # Get the default calendar folder names for all mailboxes
}, $mailboxes | ForEach-Object {
[PSCustomObject]@{ $calendarFolderName = [string](Get-EXOMailboxFolderStatistics $_.PrimarySmtpAddress -FolderScope Calendar | Where-Object { $_.FolderType -eq 'Calendar' }).Name
Calendar = "SMBuser2@domain.com" $calendarFolders[$_.PrimarySmtpAddress] = $calendarFolderName
URL = "https://example.com/calendar/smbuser2" }
}, # Get the calendar folder settings for each mailbox
[PSCustomObject]@{ foreach ($mailbox in $mailboxes) {
Calendar = "SMBuser4@domain.com" $primarySmtpAddress = $mailbox.PrimarySmtpAddress
URL = "https://example.com/calendar/smbuser3" $calendarFolder = $calendarFolders[$primarySmtpAddress]
# Get users calendar folder settings for their default Calendar folder
$calendar = Get-MailboxCalendarFolder -Identity "$primarySmtpAddress:\$calendarFolder"
# Check if calendar publishing is enabled and display a message
if ($calendar.PublishEnabled) {
Write-Host -ForegroundColor Yellow "Calendar publishing is enabled for $primarySmtpAddress on $($calendar.PublishedCalendarUrl)"
} }
) }
#> '@
$calendarDetails = Get-CISExoOutput -Rec "$("$recnum" + "b")" # Step: Prepare failure reasons and details based on compliance (Condition A & B: Fail)
# Build the failure reason string
$failureReasons = if (-not $isExternalSharingDisabled) { $failureReasons = if (-not $isExternalSharingDisabled) {
$baseMessage = "Calendar sharing with external users is enabled in one or more policies." "Calendar sharing with external users is enabled in one or more policies.`n`n" + `
if ($calendarDetails.Count -gt 0) { "Use the following command to verify which users are sharing calendars prior to disabling:`n`n" + `
$baseMessage += "`nPrior to remediating, check the following mailboxes that have calendar publishing enabled: `n$($calendarDetails -join '`n')" $failureRemediation
}
$baseMessage
} }
else { else {
"N/A" "N/A"
} }
# Step: Prepare details for the audit result (Condition A & B: Pass/Fail) # Step: Prepare details for the audit result (Condition A & B: Pass/Fail)
$details = if ($isExternalSharingDisabled) { $details = if ($isExternalSharingDisabled) {
"Calendar sharing with external users is disabled." "Calendar sharing with external users is disabled."
} }
else { else {
"Enabled Sharing Policies:`n$($sharingPolicyDetails -join ', ')" "Enabled Sharing Policies: $($sharingPolicyDetails -join ', ')"
} }
# Step: Create and populate the CISAuditResult object # Step: Create and populate the CISAuditResult object
$params = @{ $params = @{
Rec = $recnum Rec = $recnum
@@ -99,6 +98,7 @@ function Test-ExternalSharingCalendars {
$auditResult = Get-TestError -LastError $LastError -recnum $recnum $auditResult = Get-TestError -LastError $LastError -recnum $recnum
} }
} }
end { end {
# Return the audit result # Return the audit result
return $auditResult return $auditResult

View File

@@ -4,7 +4,6 @@ function Test-GlobalAdminsCount {
param ( param (
# Define your parameters here if needed # Define your parameters here if needed
) )
begin { begin {
# Dot source the class script if necessary # Dot source the class script if necessary
#. .\source\Classes\CISAuditResult.ps1 #. .\source\Classes\CISAuditResult.ps1
@@ -23,23 +22,19 @@ function Test-GlobalAdminsCount {
# - Condition A: The number of global admins is less than 2. # - Condition A: The number of global admins is less than 2.
# - Condition B: The number of global admins is more than 4. # - Condition B: The number of global admins is more than 4.
# - Condition C: Any discrepancies or errors in retrieving the list of global admin usernames. # - Condition C: Any discrepancies or errors in retrieving the list of global admin usernames.
# Initialization code, if needed # Initialization code, if needed
$recnum = "1.1.3" $recnum = "1.1.3"
Write-Verbose "Starting Test-GlobalAdminsCount with Rec: $recnum"
} }
process { process {
try { try {
$globalAdmins = Get-CISMgOutput -Rec $recnum $globalAdmins = Get-CISMgOutput -Rec $recnum
# Step: Count the number of global admins # Step: Count the number of global admins
$globalAdminCount = $globalAdmins.Count $globalAdminCount = $globalAdmins.Count
# Step: Retrieve and format the usernames of global admins # Step: Retrieve and format the usernames of global admins
$globalAdminUsernames = ($globalAdmins | ForEach-Object { $globalAdminUsernames = ($globalAdmins | ForEach-Object {
"$($_.AdditionalProperties["displayName"]) ($($_.AdditionalProperties["userPrincipalName"]))" "$($_.AdditionalProperties["displayName"]) ($($_.AdditionalProperties["userPrincipalName"]))"
}) -join ', ' }) -join ', '
# Step: Determine failure reasons based on global admin count # Step: Determine failure reasons based on global admin count
$failureReasons = if ($globalAdminCount -lt 2) { $failureReasons = if ($globalAdminCount -lt 2) {
"Less than 2 global admins: $globalAdminUsernames" "Less than 2 global admins: $globalAdminUsernames"
@@ -50,10 +45,8 @@ function Test-GlobalAdminsCount {
else { else {
"N/A" "N/A"
} }
# Step: Prepare details for the audit result # Step: Prepare details for the audit result
$details = "Count: $globalAdminCount; Users: $globalAdminUsernames" $details = "Count: $globalAdminCount; Users: $globalAdminUsernames"
# Step: Create and populate the CISAuditResult object # Step: Create and populate the CISAuditResult object
$params = @{ $params = @{
Rec = $recnum Rec = $recnum
@@ -69,7 +62,6 @@ function Test-GlobalAdminsCount {
$auditResult = Get-TestError -LastError $LastError -recnum $recnum $auditResult = Get-TestError -LastError $LastError -recnum $recnum
} }
} }
end { end {
# Return the audit result # Return the audit result
return $auditResult return $auditResult

View File

@@ -5,17 +5,14 @@ function Test-GuestAccessExpiration {
# Aligned # Aligned
# Define your parameters here if needed # Define your parameters here if needed
) )
begin { begin {
# Dot source the class script if necessary # Dot source the class script if necessary
#. .\source\Classes\CISAuditResult.ps1 #. .\source\Classes\CISAuditResult.ps1
# Initialization code, if needed # Initialization code, if needed
$recnum = "7.2.9" $recnum = "7.2.9"
Write-Verbose "Running Test-GuestAccessExpiration for $recnum..."
} }
process { process {
try { try {
# 7.2.9 (L1) Ensure guest access to a site or OneDrive will expire automatically # 7.2.9 (L1) Ensure guest access to a site or OneDrive will expire automatically
# #
@@ -32,21 +29,25 @@ function Test-GuestAccessExpiration {
# - Condition A: The ExternalUserExpirationRequired setting in SharePoint is not set to True. # - Condition A: The ExternalUserExpirationRequired setting in SharePoint is not set to True.
# - Condition B: The ExternalUserExpireInDays setting in SharePoint is configured to more than 30 days. # - Condition B: The ExternalUserExpireInDays setting in SharePoint is configured to more than 30 days.
# - Condition C: Verification using the SharePoint Admin Center indicates that guest access is not set to expire automatically after the specified number of days. # - Condition C: Verification using the SharePoint Admin Center indicates that guest access is not set to expire automatically after the specified number of days.
# Retrieve SharePoint tenant settings related to guest access expiration # Retrieve SharePoint tenant settings related to guest access expiration
# $SPOTenantGuestAccess Mock Object
<#
$SPOTenantGuestAccess = [PSCustomObject]@{
ExternalUserExpirationRequired = "$false"
ExternalUserExpireInDays = "60"
}
#>
$SPOTenantGuestAccess = Get-CISSpoOutput -Rec $recnum $SPOTenantGuestAccess = Get-CISSpoOutput -Rec $recnum
$isGuestAccessExpirationConfiguredCorrectly = $SPOTenantGuestAccess.ExternalUserExpirationRequired -and $SPOTenantGuestAccess.ExternalUserExpireInDays -le 30 $isGuestAccessExpirationConfiguredCorrectly = $SPOTenantGuestAccess.ExternalUserExpirationRequired -and $SPOTenantGuestAccess.ExternalUserExpireInDays -le 30
# Prepare failure reasons and details based on compliance # Prepare failure reasons and details based on compliance
$failureReasons = if (-not $isGuestAccessExpirationConfiguredCorrectly) { $failureReasons = if (-not $isGuestAccessExpirationConfiguredCorrectly) {
"Guest access expiration is not configured to automatically expire within 30 days or less." "Guest access expiration is not configured to automatically expire within 30 days or less. To remediate this setting, use the Set-SPOTenant command:`n`n" + `
"Set-SPOTenant -ExternalUserExpirationRequired `$true -ExternalUserExpireInDays 30"
} }
else { else {
"N/A" "N/A"
} }
$details = "ExternalUserExpirationRequired: $($SPOTenantGuestAccess.ExternalUserExpirationRequired); ExternalUserExpireInDays: $($SPOTenantGuestAccess.ExternalUserExpireInDays)" $details = "ExternalUserExpirationRequired: $($SPOTenantGuestAccess.ExternalUserExpirationRequired); ExternalUserExpireInDays: $($SPOTenantGuestAccess.ExternalUserExpireInDays)"
# Create and populate the CISAuditResult object # Create and populate the CISAuditResult object
$params = @{ $params = @{
Rec = $recnum Rec = $recnum
@@ -62,7 +63,6 @@ function Test-GuestAccessExpiration {
$auditResult = Get-TestError -LastError $LastError -recnum $recnum $auditResult = Get-TestError -LastError $LastError -recnum $recnum
} }
} }
end { end {
# Return the audit result # Return the audit result
return $auditResult return $auditResult

View File

@@ -6,14 +6,13 @@ function Test-LinkSharingRestrictions {
# Define your parameters here # Define your parameters here
# Test behavior in prod # Test behavior in prod
) )
begin { begin {
# Dot source the class script if necessary # Dot source the class script if necessary
#. .\source\Classes\CISAuditResult.ps1 #. .\source\Classes\CISAuditResult.ps1
# Initialization code, if needed # Initialization code, if needed
$recnum = "7.2.7" $recnum = "7.2.7"
Write-Verbose "Running Test-LinkSharingRestrictions for $recnum..."
} }
process { process {
try { try {
# 7.2.7 (L1) Ensure link sharing is restricted in SharePoint and OneDrive # 7.2.7 (L1) Ensure link sharing is restricted in SharePoint and OneDrive
@@ -31,21 +30,24 @@ function Test-LinkSharingRestrictions {
# - Condition A: The `DefaultSharingLinkType` setting in SharePoint and OneDrive is not set to `Direct`. # - Condition A: The `DefaultSharingLinkType` setting in SharePoint and OneDrive is not set to `Direct`.
# - Condition B: The setting `Choose the type of link that's selected by default when users share files and folders in SharePoint and OneDrive` is not set to `Specific people (only the people the user specifies)`. # - Condition B: The setting `Choose the type of link that's selected by default when users share files and folders in SharePoint and OneDrive` is not set to `Specific people (only the people the user specifies)`.
# - Condition C: Verification using the UI indicates that the link sharing settings are not configured as recommended. # - Condition C: Verification using the UI indicates that the link sharing settings are not configured as recommended.
# Retrieve link sharing configuration for SharePoint and OneDrive # Retrieve link sharing configuration for SharePoint and OneDrive
# $SPOTenantLinkSharing Mock Object
<#
$$SPOTenantLinkSharing = [PSCustomObject]@{
DefaultSharingLinkType = "Direct"
}
#>
$SPOTenantLinkSharing = Get-CISSpoOutput -Rec $recnum $SPOTenantLinkSharing = Get-CISSpoOutput -Rec $recnum
$isLinkSharingRestricted = $SPOTenantLinkSharing.DefaultSharingLinkType -eq 'Direct' # Or 'SpecificPeople' as per the recommendation $isLinkSharingRestricted = $SPOTenantLinkSharing.DefaultSharingLinkType -eq 'Direct' # Or 'SpecificPeople' as per the recommendation
# Prepare failure reasons and details based on compliance # Prepare failure reasons and details based on compliance
$failureReasons = if (-not $isLinkSharingRestricted) { $failureReasons = if (-not $isLinkSharingRestricted) {
"Link sharing is not restricted to 'Specific people'. Current setting: $($SPOTenantLinkSharing.DefaultSharingLinkType)" "Link sharing is not restricted to 'Specific people'. Current setting: $($SPOTenantLinkSharing.DefaultSharingLinkType). To remediate this setting, use the Set-SPOTenant command:`n`n" + `
"Set-SPOTenant -DefaultSharingLinkType Direct"
} }
else { else {
"N/A" "N/A"
} }
$details = "DefaultSharingLinkType: $($SPOTenantLinkSharing.DefaultSharingLinkType)" $details = "DefaultSharingLinkType: $($SPOTenantLinkSharing.DefaultSharingLinkType)"
# Create and populate the CISAuditResult object # Create and populate the CISAuditResult object
$params = @{ $params = @{
Rec = $recnum Rec = $recnum
@@ -55,14 +57,12 @@ function Test-LinkSharingRestrictions {
FailureReason = $failureReasons FailureReason = $failureReasons
} }
$auditResult = Initialize-CISAuditResult @params $auditResult = Initialize-CISAuditResult @params
} }
catch { catch {
$LastError = $_ $LastError = $_
$auditResult = Get-TestError -LastError $LastError -recnum $recnum $auditResult = Get-TestError -LastError $LastError -recnum $recnum
} }
} }
end { end {
# Return the audit result # Return the audit result
return $auditResult return $auditResult

View File

@@ -24,13 +24,15 @@ function Test-MailboxAuditingE3 {
#> #>
# Dot source the class script if necessary # Dot source the class script if necessary
#. .\source\Classes\CISAuditResult.ps1 #. .\source\Classes\CISAuditResult.ps1
$actionDictionaries = Get-Action -Dictionaries
# E3 specific actions
$AdminActions = $actionDictionaries.AdminActions.Keys | Where-Object { $_ -notin @("MailItemsAccessed", "Send") }
$DelegateActions = $actionDictionaries.DelegateActions.Keys | Where-Object { $_ -notin @("MailItemsAccessed") }
$OwnerActions = $actionDictionaries.OwnerActions.Keys | Where-Object { $_ -notin @("MailItemsAccessed", "Send") }
$allFailures = @()
$recnum = "6.1.2" $recnum = "6.1.2"
$version = $recnum
$actionDictionaries = Get-Action -Dictionaries -Version $version
# E3 specific actions
$AdminActions = $actionDictionaries.AdminActions.Keys
$DelegateActions = $actionDictionaries.DelegateActions.Keys
$OwnerActions = $actionDictionaries.OwnerActions.Keys
$allFailures = @()
Write-Verbose "Running Test-MailboxAuditingE3 for $recnum..." Write-Verbose "Running Test-MailboxAuditingE3 for $recnum..."
$allUsers = Get-CISMgOutput -Rec $recnum $allUsers = Get-CISMgOutput -Rec $recnum
$processedUsers = @{} # Dictionary to track processed users $processedUsers = @{} # Dictionary to track processed users
@@ -52,17 +54,17 @@ function Test-MailboxAuditingE3 {
if ($mailbox.AuditEnabled) { if ($mailbox.AuditEnabled) {
foreach ($action in $AdminActions) { foreach ($action in $AdminActions) {
if ($mailbox.AuditAdmin -notcontains $action) { if ($mailbox.AuditAdmin -notcontains $action) {
$missingAdminActions += (Get-Action -Actions $action -ActionType "Admin") $missingAdminActions += (Get-Action -Actions $action -ActionType "Admin" -Version $version)
} }
} }
foreach ($action in $DelegateActions) { foreach ($action in $DelegateActions) {
if ($mailbox.AuditDelegate -notcontains $action) { if ($mailbox.AuditDelegate -notcontains $action) {
$missingDelegateActions += (Get-Action -Actions $action -ActionType "Delegate") $missingDelegateActions += (Get-Action -Actions $action -ActionType "Delegate" -Version $version)
} }
} }
foreach ($action in $OwnerActions) { foreach ($action in $OwnerActions) {
if ($mailbox.AuditOwner -notcontains $action) { if ($mailbox.AuditOwner -notcontains $action) {
$missingOwnerActions += (Get-Action -Actions $action -ActionType "Owner") $missingOwnerActions += (Get-Action -Actions $action -ActionType "Owner" -Version $version)
} }
} }
if ($missingAdminActions.Count -gt 0 -or $missingDelegateActions.Count -gt 0 -or $missingOwnerActions.Count -gt 0) { if ($missingAdminActions.Count -gt 0 -or $missingDelegateActions.Count -gt 0 -or $missingOwnerActions.Count -gt 0) {
@@ -99,7 +101,7 @@ function Test-MailboxAuditingE3 {
$auditResult = Initialize-CISAuditResult @params $auditResult = Initialize-CISAuditResult @params
} }
catch { catch {
Write-Error "An error occurred during the test: $_" Write-Error "An error occurred during the test $recnum`:: $_"
# Retrieve the description from the test definitions # Retrieve the description from the test definitions
$testDefinition = $script:TestDefinitionsObject | Where-Object { $_.Rec -eq $recnum } $testDefinition = $script:TestDefinitionsObject | Where-Object { $_.Rec -eq $recnum }
$description = if ($testDefinition) { $testDefinition.RecDescription } else { "Description not found" } $description = if ($testDefinition) { $testDefinition.RecDescription } else { "Description not found" }

View File

@@ -24,13 +24,14 @@ function Test-MailboxAuditingE5 {
# - Condition B: AuditAdmin actions do not include all of the following: ApplyRecord, Create, HardDelete, MailItemsAccessed, MoveToDeletedItems, Send, SendAs, SendOnBehalf, SoftDelete, Update, UpdateCalendarDelegation, UpdateFolderPermissions, UpdateInboxRules. # - Condition B: AuditAdmin actions do not include all of the following: ApplyRecord, Create, HardDelete, MailItemsAccessed, MoveToDeletedItems, Send, SendAs, SendOnBehalf, SoftDelete, Update, UpdateCalendarDelegation, UpdateFolderPermissions, UpdateInboxRules.
# - Condition C: AuditDelegate actions do not include all of the following: ApplyRecord, Create, HardDelete, MailItemsAccessed, MoveToDeletedItems, SendAs, SendOnBehalf, SoftDelete, Update, UpdateFolderPermissions, UpdateInboxRules. # - Condition C: AuditDelegate actions do not include all of the following: ApplyRecord, Create, HardDelete, MailItemsAccessed, MoveToDeletedItems, SendAs, SendOnBehalf, SoftDelete, Update, UpdateFolderPermissions, UpdateInboxRules.
# - Condition D: AuditOwner actions do not include all of the following: ApplyRecord, HardDelete, MailItemsAccessed, MoveToDeletedItems, Send, SoftDelete, Update, UpdateCalendarDelegation, UpdateFolderPermissions, UpdateInboxRules. # - Condition D: AuditOwner actions do not include all of the following: ApplyRecord, HardDelete, MailItemsAccessed, MoveToDeletedItems, Send, SoftDelete, Update, UpdateCalendarDelegation, UpdateFolderPermissions, UpdateInboxRules.
$actionDictionaries = Get-Action -Dictionaries $recnum = "6.1.3"
$version = $recnum
$actionDictionaries = Get-Action -Dictionaries -Version $version
$AdminActions = $actionDictionaries.AdminActions.Keys $AdminActions = $actionDictionaries.AdminActions.Keys
$DelegateActions = $actionDictionaries.DelegateActions.Keys $DelegateActions = $actionDictionaries.DelegateActions.Keys
$OwnerActions = $actionDictionaries.OwnerActions.Keys $OwnerActions = $actionDictionaries.OwnerActions.Keys
$allFailures = @() $allFailures = @()
$processedUsers = @{} $processedUsers = @{}
$recnum = "6.1.3"
Write-Verbose "Running Test-MailboxAuditingE5 for $recnum..." Write-Verbose "Running Test-MailboxAuditingE5 for $recnum..."
$allUsers = Get-CISMgOutput -Rec $recnum $allUsers = Get-CISMgOutput -Rec $recnum
} }
@@ -52,19 +53,19 @@ function Test-MailboxAuditingE5 {
# Validate Admin actions # Validate Admin actions
foreach ($action in $AdminActions) { foreach ($action in $AdminActions) {
if ($mailbox.AuditAdmin -notcontains $action) { if ($mailbox.AuditAdmin -notcontains $action) {
$missingAdminActions += (Get-Action -Actions $action -ActionType "Admin") # Condition B $missingAdminActions += (Get-Action -Actions $action -ActionType "Admin" -Version $version) # Condition B
} }
} }
# Validate Delegate actions # Validate Delegate actions
foreach ($action in $DelegateActions) { foreach ($action in $DelegateActions) {
if ($mailbox.AuditDelegate -notcontains $action) { if ($mailbox.AuditDelegate -notcontains $action) {
$missingDelegateActions += (Get-Action -Actions $action -ActionType "Delegate") # Condition C $missingDelegateActions += (Get-Action -Actions $action -ActionType "Delegate" -Version $version) # Condition C
} }
} }
# Validate Owner actions # Validate Owner actions
foreach ($action in $OwnerActions) { foreach ($action in $OwnerActions) {
if ($mailbox.AuditOwner -notcontains $action) { if ($mailbox.AuditOwner -notcontains $action) {
$missingOwnerActions += (Get-Action -Actions $action -ActionType "Owner") # Condition D $missingOwnerActions += (Get-Action -Actions $action -ActionType "Owner" -Version $version) # Condition D
} }
} }
if ($missingAdminActions.Count -gt 0 -or $missingDelegateActions.Count -gt 0 -or $missingOwnerActions.Count -gt 0) { if ($missingAdminActions.Count -gt 0 -or $missingDelegateActions.Count -gt 0 -or $missingOwnerActions.Count -gt 0) {
@@ -102,7 +103,7 @@ function Test-MailboxAuditingE5 {
$auditResult = Initialize-CISAuditResult @params $auditResult = Initialize-CISAuditResult @params
} }
catch { catch {
Write-Error "An error occurred during the test: $_" Write-Error "An error occurred during the test $recnum`:: $_"
# Retrieve the description from the test definitions # Retrieve the description from the test definitions
$testDefinition = $script:TestDefinitionsObject | Where-Object { $_.Rec -eq $recnum } $testDefinition = $script:TestDefinitionsObject | Where-Object { $_.Rec -eq $recnum }
$description = if ($testDefinition) { $testDefinition.RecDescription } else { "Description not found" } $description = if ($testDefinition) { $testDefinition.RecDescription } else { "Description not found" }

View File

@@ -4,14 +4,12 @@ function Test-ManagedApprovedPublicGroups {
param ( param (
# Parameters can be added if needed # Parameters can be added if needed
) )
begin { begin {
# Dot source the class script if necessary # Dot source the class script if necessary
#. .\source\Classes\CISAuditResult.ps1 #. .\source\Classes\CISAuditResult.ps1
# Initialization code, if needed # Initialization code, if needed
$recnum = "1.2.1" $recnum = "1.2.1"
Write-Verbose "Starting Test-ManagedApprovedPublicGroups with Rec: $recnum"
# Conditions for 1.2.1 (L2) Ensure that only organizationally managed/approved public groups exist (Automated) # Conditions for 1.2.1 (L2) Ensure that only organizationally managed/approved public groups exist (Automated)
# #
# Validate test for a pass: # Validate test for a pass:
@@ -26,12 +24,10 @@ function Test-ManagedApprovedPublicGroups {
# - Condition A: One or more groups have the status 'Public' in the privacy column on the Active teams and groups page. # - Condition A: One or more groups have the status 'Public' in the privacy column on the Active teams and groups page.
# - Condition B: Using Microsoft Graph PowerShell, one or more groups return a status of 'Public' when checked. # - Condition B: Using Microsoft Graph PowerShell, one or more groups return a status of 'Public' when checked.
} }
process { process {
try { try {
# Step: Retrieve all groups with visibility set to 'Public' # Step: Retrieve all groups with visibility set to 'Public'
$allGroups = Get-CISMgOutput -Rec $recnum $allGroups = Get-CISMgOutput -Rec $recnum
# Step: Determine failure reasons based on the presence of public groups # Step: Determine failure reasons based on the presence of public groups
$failureReasons = if ($null -ne $allGroups -and $allGroups.Count -gt 0) { $failureReasons = if ($null -ne $allGroups -and $allGroups.Count -gt 0) {
"There are public groups present that are not organizationally managed/approved." "There are public groups present that are not organizationally managed/approved."
@@ -39,7 +35,6 @@ function Test-ManagedApprovedPublicGroups {
else { else {
"N/A" "N/A"
} }
# Step: Prepare details for the audit result # Step: Prepare details for the audit result
$details = if ($null -eq $allGroups -or $allGroups.Count -eq 0) { $details = if ($null -eq $allGroups -or $allGroups.Count -eq 0) {
"No public groups found." "No public groups found."
@@ -48,7 +43,6 @@ function Test-ManagedApprovedPublicGroups {
$groupDetails = $allGroups | ForEach-Object { $_.DisplayName + " (" + $_.Visibility + ")" } $groupDetails = $allGroups | ForEach-Object { $_.DisplayName + " (" + $_.Visibility + ")" }
"Public groups found: $($groupDetails -join ', ')" "Public groups found: $($groupDetails -join ', ')"
} }
# Step: Create and populate the CISAuditResult object # Step: Create and populate the CISAuditResult object
$params = @{ $params = @{
Rec = $recnum Rec = $recnum
@@ -64,7 +58,6 @@ function Test-ManagedApprovedPublicGroups {
$auditResult = Get-TestError -LastError $LastError -recnum $recnum $auditResult = Get-TestError -LastError $LastError -recnum $recnum
} }
} }
end { end {
# Return the audit result # Return the audit result
return $auditResult return $auditResult

View File

@@ -12,16 +12,14 @@ function Test-ModernAuthSharePoint {
# Initialization code, if needed # Initialization code, if needed
$recnum = "7.2.1" $recnum = "7.2.1"
Write-Verbose "Running Test-ModernAuthSharePoint for $recnum..."
<# <#
# Conditions for 7.2.1 (L1) Ensure modern authentication for SharePoint applications is required # Conditions for 7.2.1 (L1) Ensure modern authentication for SharePoint applications is required
## Validate test for a pass: ## Validate test for a pass:
# - Confirm that the automated test results align with the manual audit steps outlined in the CIS benchmark. # - Confirm that the automated test results align with the manual audit steps outlined in the CIS benchmark.
# - Specific conditions to check: # - Specific conditions to check:
# - Condition A: The setting "Apps that don't use modern authentication" is set to "Block access" in the SharePoint admin center. # - Condition A: The setting "Apps that don't use modern authentication" is set to "Block access" in the SharePoint admin center.
# - Condition B: The PowerShell command `Get-SPOTenant | ft LegacyAuthProtocolsEnabled` returns `False`. # - Condition B: The PowerShell command `Get-SPOTenant | ft LegacyAuthProtocolsEnabled` returns `False`.
## Validate test for a fail: ## Validate test for a fail:
# - Confirm that the failure conditions in the automated test are consistent with the manual audit results. # - Confirm that the failure conditions in the automated test are consistent with the manual audit results.
# - Specific conditions to check: # - Specific conditions to check:
@@ -29,23 +27,25 @@ function Test-ModernAuthSharePoint {
# - Condition B: The PowerShell command `Get-SPOTenant | ft LegacyAuthProtocolsEnabled` returns `True`. # - Condition B: The PowerShell command `Get-SPOTenant | ft LegacyAuthProtocolsEnabled` returns `True`.
#> #>
} }
process { process {
try { try {
# 7.2.1 (L1) Ensure modern authentication for SharePoint applications is required # 7.2.1 (L1) Ensure modern authentication for SharePoint applications is required
# $SPOTenant Mock Object
<#
$SPOTenant = [PSCustomObject]@{
LegacyAuthProtocolsEnabled = $true
}
#>
$SPOTenant = Get-CISSpoOutput -Rec $recnum $SPOTenant = Get-CISSpoOutput -Rec $recnum
$modernAuthForSPRequired = -not $SPOTenant.LegacyAuthProtocolsEnabled $modernAuthForSPRequired = -not $SPOTenant.LegacyAuthProtocolsEnabled
# Prepare failure reasons and details based on compliance # Prepare failure reasons and details based on compliance
$failureReasons = if (-not $modernAuthForSPRequired) { $failureReasons = if (-not $modernAuthForSPRequired) {
"Legacy authentication protocols are enabled" # Fail Condition B "Legacy authentication protocols are enabled. The following command can be used to disable:`nSet-SPOTenant -LegacyAuthProtocolsEnabled `$false" # Fail Condition B
} }
else { else {
"N/A" "N/A"
} }
$details = "LegacyAuthProtocolsEnabled: $($SPOTenant.LegacyAuthProtocolsEnabled)" # Details for Condition B $details = "LegacyAuthProtocolsEnabled: $($SPOTenant.LegacyAuthProtocolsEnabled)" # Details for Condition B
# Create and populate the CISAuditResult object # Create and populate the CISAuditResult object
$params = @{ $params = @{
Rec = $recnum Rec = $recnum
@@ -61,7 +61,6 @@ function Test-ModernAuthSharePoint {
$auditResult = Get-TestError -LastError $LastError -recnum $recnum $auditResult = Get-TestError -LastError $LastError -recnum $recnum
} }
} }
end { end {
# Return the audit result # Return the audit result
return $auditResult return $auditResult

View File

@@ -5,7 +5,6 @@ function Test-OneDriveContentRestrictions {
# Aligned # Aligned
# Define your parameters here # Define your parameters here
) )
begin { begin {
# 7.2.4 (L2) Ensure OneDrive content sharing is restricted # 7.2.4 (L2) Ensure OneDrive content sharing is restricted
# #
@@ -22,36 +21,38 @@ function Test-OneDriveContentRestrictions {
# - Condition A: The OneDriveSharingCapability setting is not configured to "Disabled" using the PowerShell cmdlet `Get-SPOTenant | fl OneDriveSharingCapability`. # - Condition A: The OneDriveSharingCapability setting is not configured to "Disabled" using the PowerShell cmdlet `Get-SPOTenant | fl OneDriveSharingCapability`.
# - Condition B: The OneDriveSharingCapability is not set to "Only people in your organization" in the SharePoint admin center under Policies > Sharing > OneDrive. # - Condition B: The OneDriveSharingCapability is not set to "Only people in your organization" in the SharePoint admin center under Policies > Sharing > OneDrive.
# - Condition C: OneDrive content sharing is more permissive than SharePoint content sharing. # - Condition C: OneDrive content sharing is more permissive than SharePoint content sharing.
# Dot source the class script if necessary # Dot source the class script if necessary
#. .\source\Classes\CISAuditResult.ps1 #. .\source\Classes\CISAuditResult.ps1
# Initialization code, if needed # Initialization code, if needed
$recnum = "7.2.4" $recnum = "7.2.4"
Write-Verbose "Running Test-OneDriveContentRestrictions for $recnum..."
} }
process { process {
try { try {
# 7.2.4 (L2) Ensure OneDrive content sharing is restricted # 7.2.4 (L2) Ensure OneDrive content sharing is restricted
# Retrieve OneDrive sharing capability settings # Retrieve OneDrive sharing capability settings
# $SPOTenant Mock Object
<#
$SPOTenant = [PSCustomObject]@{
OneDriveSharingCapability = "ExternalUserAndGuestSharing"
}
#>
$SPOTenant = Get-CISSpoOutput -Rec $recnum $SPOTenant = Get-CISSpoOutput -Rec $recnum
$isOneDriveSharingRestricted = $SPOTenant.OneDriveSharingCapability -eq 'Disabled' $isOneDriveSharingRestricted = $SPOTenant.OneDriveSharingCapability -eq 'Disabled'
# Prepare failure reasons and details based on compliance # Prepare failure reasons and details based on compliance
$failureReasons = if (-not $isOneDriveSharingRestricted) { $failureReasons = if (-not $isOneDriveSharingRestricted) {
"OneDrive content sharing is not restricted to 'Disabled'. Current setting: $($SPOTenant.OneDriveSharingCapability)" "OneDrive content sharing is not restricted to 'Disabled'. To remediate this setting, use the Set-SPOTenant command.`n`n" + `
"Set-SPOTenant -OneDriveSharingCapability Disabled"
} }
else { else {
"N/A" "N/A"
} }
$details = if ($isOneDriveSharingRestricted) { $details = if ($isOneDriveSharingRestricted) {
"OneDrive content sharing is restricted." "OneDrive content sharing is restricted."
} }
else { else {
"OneDriveSharingCapability: $($SPOTenant.OneDriveSharingCapability)" "OneDriveSharingCapability: $($SPOTenant.OneDriveSharingCapability)"
} }
# Create and populate the CISAuditResult object # Create and populate the CISAuditResult object
$params = @{ $params = @{
Rec = $recnum Rec = $recnum
@@ -67,7 +68,6 @@ function Test-OneDriveContentRestrictions {
$auditResult = Get-TestError -LastError $LastError -recnum $recnum $auditResult = Get-TestError -LastError $LastError -recnum $recnum
} }
} }
end { end {
# Return auditResult # Return auditResult
return $auditResult return $auditResult

View File

@@ -5,14 +5,13 @@ function Test-OneDriveSyncRestrictions {
# Aligned # Aligned
# Define your parameters here # Define your parameters here
) )
begin { begin {
# Dot source the class script if necessary # Dot source the class script if necessary
#. .\source\Classes\CISAuditResult.ps1 #. .\source\Classes\CISAuditResult.ps1
# Initialization code, if needed # Initialization code, if needed
$recnum = "7.3.2" $recnum = "7.3.2"
Write-Verbose "Running Test-OneDriveSyncRestrictions for $recnum..."
} }
process { process {
try { try {
# 7.3.2 (L2) Ensure OneDrive sync is restricted for unmanaged devices # 7.3.2 (L2) Ensure OneDrive sync is restricted for unmanaged devices
@@ -30,20 +29,20 @@ function Test-OneDriveSyncRestrictions {
# - Condition A: "Allow syncing only on computers joined to specific domains" is not enabled. # - Condition A: "Allow syncing only on computers joined to specific domains" is not enabled.
# - Condition B: "TenantRestrictionEnabled" is set to False. # - Condition B: "TenantRestrictionEnabled" is set to False.
# - Condition C: "AllowedDomainList" does not contain the trusted domain GUIDs from the on-premises environment. # - Condition C: "AllowedDomainList" does not contain the trusted domain GUIDs from the on-premises environment.
# Retrieve OneDrive sync client restriction settings # Retrieve OneDrive sync client restriction settings
$SPOTenantSyncClientRestriction = Get-CISSpoOutput -Rec $recnum $SPOTenantSyncClientRestriction = Get-CISSpoOutput -Rec $recnum
$isSyncRestricted = $SPOTenantSyncClientRestriction.TenantRestrictionEnabled -and $SPOTenantSyncClientRestriction.AllowedDomainList $isSyncRestricted = $SPOTenantSyncClientRestriction.TenantRestrictionEnabled -and $SPOTenantSyncClientRestriction.AllowedDomainList
# Condition A: Check if TenantRestrictionEnabled is True # Condition A: Check if TenantRestrictionEnabled is True
# Condition B: Ensure AllowedDomainList contains trusted domains GUIDs # Condition B: Ensure AllowedDomainList contains trusted domains GUIDs
$failureReasons = if (-not $isSyncRestricted) { $failureReasons = if (-not $isSyncRestricted) {
"OneDrive sync is not restricted to managed devices. TenantRestrictionEnabled should be True and AllowedDomainList should contain trusted domains GUIDs." "OneDrive sync is not restricted to managed devices. For hybrid devices, TenantRestrictionEnabled should be True and AllowedDomainList should contain trusted domains GUIDs.`n" + `
"To remediate this setting, edit and use the Set-SPOTenantSyncClientRestriction command below:`n" + `
"Set-SPOTenantSyncClientRestriction -TenantRestrictionEnabled `$true -AllowedDomainList `"<GUID1>`",`"<GUID2>`"`n`n" + `
"Note: Utilize the -BlockMacSync:`$true parameter if you are not using conditional access to ensure Macs cannot sync."
} }
else { else {
"N/A" "N/A"
} }
# Condition C: Prepare details based on whether sync is restricted # Condition C: Prepare details based on whether sync is restricted
$details = if ($isSyncRestricted) { $details = if ($isSyncRestricted) {
"OneDrive sync is restricted for unmanaged devices." "OneDrive sync is restricted for unmanaged devices."
@@ -51,7 +50,6 @@ function Test-OneDriveSyncRestrictions {
else { else {
"TenantRestrictionEnabled: $($SPOTenantSyncClientRestriction.TenantRestrictionEnabled); AllowedDomainList: $($SPOTenantSyncClientRestriction.AllowedDomainList -join ', ')" "TenantRestrictionEnabled: $($SPOTenantSyncClientRestriction.TenantRestrictionEnabled); AllowedDomainList: $($SPOTenantSyncClientRestriction.AllowedDomainList -join ', ')"
} }
# Create and populate the CISAuditResult object # Create and populate the CISAuditResult object
$params = @{ $params = @{
Rec = $recnum Rec = $recnum
@@ -67,7 +65,6 @@ function Test-OneDriveSyncRestrictions {
$auditResult = Get-TestError -LastError $LastError -recnum $recnum $auditResult = Get-TestError -LastError $LastError -recnum $recnum
} }
} }
end { end {
# Return auditResult # Return auditResult
return $auditResult return $auditResult

View File

@@ -5,7 +5,6 @@ function Test-PasswordHashSync {
# Aligned # Aligned
# Parameters can be added if needed # Parameters can be added if needed
) )
begin { begin {
# Conditions for 5.1.8.1 (L1) Ensure password hash sync is enabled for hybrid deployments # Conditions for 5.1.8.1 (L1) Ensure password hash sync is enabled for hybrid deployments
# #
@@ -22,21 +21,18 @@ function Test-PasswordHashSync {
# - Condition A: Password hash sync is not enabled in the Azure AD Connect tool on the on-premises server. # - Condition A: Password hash sync is not enabled in the Azure AD Connect tool on the on-premises server.
# - Condition B: Password hash sync is not verified as enabled in the Azure AD Connect Sync section in the Microsoft Entra admin center. # - Condition B: Password hash sync is not verified as enabled in the Azure AD Connect Sync section in the Microsoft Entra admin center.
# - Condition C: Using Microsoft Graph PowerShell, the verification command returns no result indicating that password sync is not enabled for the on-premises AD. # - Condition C: Using Microsoft Graph PowerShell, the verification command returns no result indicating that password sync is not enabled for the on-premises AD.
# Dot source the class script if necessary # Dot source the class script if necessary
#. .\source\Classes\CISAuditResult.ps1 #. .\source\Classes\CISAuditResult.ps1
# Initialization code, if needed # Initialization code, if needed
$recnum = "5.1.8.1" $recnum = "5.1.8.1"
Write-Verbose "Starting Test-PasswordHashSync with Rec: $recnum"
} }
process { process {
try { try {
# 5.1.8.1 (L1) Ensure password hash sync is enabled for hybrid deployments # 5.1.8.1 (L1) Ensure password hash sync is enabled for hybrid deployments
# Retrieve password hash sync status (Condition A and C) # Retrieve password hash sync status (Condition A and C)
$passwordHashSync = Get-CISMgOutput -Rec $recnum $passwordHashSync = Get-CISMgOutput -Rec $recnum
$hashSyncResult = $passwordHashSync $hashSyncResult = $passwordHashSync
# Prepare failure reasons and details based on compliance # Prepare failure reasons and details based on compliance
$failureReasons = if (-not $hashSyncResult) { $failureReasons = if (-not $hashSyncResult) {
"Password hash sync for hybrid deployments is not enabled" "Password hash sync for hybrid deployments is not enabled"
@@ -44,9 +40,7 @@ function Test-PasswordHashSync {
else { else {
"N/A" "N/A"
} }
$details = "OnPremisesSyncEnabled: $($passwordHashSync)" $details = "OnPremisesSyncEnabled: $($passwordHashSync)"
# Create and populate the CISAuditResult object # Create and populate the CISAuditResult object
$params = @{ $params = @{
Rec = $recnum Rec = $recnum
@@ -62,7 +56,6 @@ function Test-PasswordHashSync {
$auditResult = Get-TestError -LastError $LastError -recnum $recnum $auditResult = Get-TestError -LastError $LastError -recnum $recnum
} }
} }
end { end {
# Return the audit result # Return the audit result
return $auditResult return $auditResult

View File

@@ -45,13 +45,12 @@ function Test-PasswordNeverExpirePolicy {
$isDefault = $domain.IsDefault $isDefault = $domain.IsDefault
# Step (Condition C): Determine if the notification window is set to 30 days # Step (Condition C): Determine if the notification window is set to 30 days
$notificationWindow = $domain.PasswordNotificationWindowInDays $notificationWindow = $domain.PasswordNotificationWindowInDays
$notificationPolIsCompliant = $notificationWindow -eq 30 $notificationPolIsCompliant = $true # No longer a requirement
# Step (Condition A): Retrieve password expiration policy # Step (Condition A): Retrieve password expiration policy
$passwordPolicy = $domain.PasswordValidityPeriodInDays $passwordPolicy = $domain.PasswordValidityPeriodInDays
$pwPolIsCompliant = $passwordPolicy -eq 2147483647 $pwPolIsCompliant = $passwordPolicy -eq 2147483647
# Step (Condition A & B): Determine if the policy is compliant # Step (Condition A & B): Determine if the policy is compliant
$overallResult = $overallResult -and $notificationPolIsCompliant -and $pwPolIsCompliant $overallResult = $overallResult -and $notificationPolIsCompliant -and $pwPolIsCompliant
# Step (Condition A & B): Prepare failure reasons and details based on compliance # Step (Condition A & B): Prepare failure reasons and details based on compliance
$failureReasons = if ($notificationPolIsCompliant -and $pwPolIsCompliant) { $failureReasons = if ($notificationPolIsCompliant -and $pwPolIsCompliant) {
"N/A" "N/A"
@@ -59,18 +58,14 @@ function Test-PasswordNeverExpirePolicy {
else { else {
"Password expiration is not set to never expire or notification window is not set to 30 days for domain $domainName. Run the following command to remediate: `nUpdate-MgDomain -DomainId $domainName -PasswordValidityPeriodInDays 2147483647 -PasswordNotificationWindowInDays 30`n" "Password expiration is not set to never expire or notification window is not set to 30 days for domain $domainName. Run the following command to remediate: `nUpdate-MgDomain -DomainId $domainName -PasswordValidityPeriodInDays 2147483647 -PasswordNotificationWindowInDays 30`n"
} }
$details = "$domainName|$passwordPolicy days|$notificationWindow days|$isDefault" $details = "$domainName|$passwordPolicy days|$notificationWindow days|$isDefault"
# Add details and failure reasons to the lists # Add details and failure reasons to the lists
$detailsList += $details $detailsList += $details
$failureReasonsList += $failureReasons $failureReasonsList += $failureReasons
} }
# Prepare the final failure reason and details # Prepare the final failure reason and details
$finalFailureReason = $failureReasonsList -join "`n" $finalFailureReason = $failureReasonsList -join "`n"
$finalDetails = $detailsList -join "`n" $finalDetails = $detailsList -join "`n"
# Step: Create and populate the CISAuditResult object # Step: Create and populate the CISAuditResult object
$params = @{ $params = @{
Rec = $recnum Rec = $recnum
@@ -86,7 +81,6 @@ function Test-PasswordNeverExpirePolicy {
$auditResult = Get-TestError -LastError $LastError -recnum $recnum $auditResult = Get-TestError -LastError $LastError -recnum $recnum
} }
} }
end { end {
# Return the audit result # Return the audit result
return $auditResult return $auditResult

View File

@@ -5,7 +5,6 @@ function Test-ReauthWithCode {
# Aligned # Aligned
# Define your parameters here # Define your parameters here
) )
begin { begin {
<# <#
Conditions for 7.2.10 (L1) Ensure reauthentication with verification code is restricted Conditions for 7.2.10 (L1) Ensure reauthentication with verification code is restricted
@@ -22,31 +21,34 @@ function Test-ReauthWithCode {
# - Condition A: The `EmailAttestationRequired` property is set to `False`. # - Condition A: The `EmailAttestationRequired` property is set to `False`.
# - Condition B: The `EmailAttestationReAuthDays` property is set to more than `15`. # - Condition B: The `EmailAttestationReAuthDays` property is set to more than `15`.
#> #>
# Dot source the class script if necessary # Dot source the class script if necessary
#. .\source\Classes\CISAuditResult.ps1 #. .\source\Classes\CISAuditResult.ps1
# Initialization code, if needed # Initialization code, if needed
$recnum = "7.2.10" $recnum = "7.2.10"
Write-Verbose "Running Test-ReauthWithCode for $recnum..."
} }
process { process {
try { try {
# 7.2.10 (L1) Ensure reauthentication with verification code is restricted # 7.2.10 (L1) Ensure reauthentication with verification code is restricted
# Retrieve reauthentication settings for SharePoint Online # Retrieve reauthentication settings for SharePoint Online
# $SPOTenantReauthentication Mock Object
<#
$SPOTenantReauthentication = [PSCustomObject]@{
EmailAttestationRequired = "$false"
EmailAttestationReAuthDays = "30"
}
#>
$SPOTenantReauthentication = Get-CISSpoOutput -Rec $recnum $SPOTenantReauthentication = Get-CISSpoOutput -Rec $recnum
$isReauthenticationRestricted = $SPOTenantReauthentication.EmailAttestationRequired -and $SPOTenantReauthentication.EmailAttestationReAuthDays -le 15 $isReauthenticationRestricted = $SPOTenantReauthentication.EmailAttestationRequired -and $SPOTenantReauthentication.EmailAttestationReAuthDays -le 15
# Prepare failure reasons and details based on compliance # Prepare failure reasons and details based on compliance
$failureReasons = if (-not $isReauthenticationRestricted) { $failureReasons = if (-not $isReauthenticationRestricted) {
"Reauthentication with verification code does not require reauthentication within 15 days or less." "Reauthentication with verification code does not require reauthentication within 15 days or less. To remediate this setting, use the Set-SPOTenant command:`n" + `
"Set-SPOTenant -EmailAttestationRequired `$true -EmailAttestationReAuthDays 15"
} }
else { else {
"N/A" "N/A"
} }
$details = "EmailAttestationRequired: $($SPOTenantReauthentication.EmailAttestationRequired); EmailAttestationReAuthDays: $($SPOTenantReauthentication.EmailAttestationReAuthDays)" $details = "EmailAttestationRequired: $($SPOTenantReauthentication.EmailAttestationRequired); EmailAttestationReAuthDays: $($SPOTenantReauthentication.EmailAttestationReAuthDays)"
# Create and populate the CISAuditResult object # Create and populate the CISAuditResult object
$params = @{ $params = @{
Rec = $recnum Rec = $recnum
@@ -62,7 +64,6 @@ function Test-ReauthWithCode {
$auditResult = Get-TestError -LastError $LastError -recnum $recnum $auditResult = Get-TestError -LastError $LastError -recnum $recnum
} }
} }
end { end {
# Return auditResult # Return auditResult
return $auditResult return $auditResult

View File

@@ -4,15 +4,13 @@ function Test-RestrictCustomScripts {
param ( param (
# Define your parameters here if needed # Define your parameters here if needed
) )
begin { begin {
# Dot source the class script if necessary # Dot source the class script if necessary
# . .\source\Classes\CISAuditResult.ps1 # . .\source\Classes\CISAuditResult.ps1
# Initialization code, if needed # Initialization code, if needed
$recnum = "7.3.4" $recnum = "7.3.4"
Write-Verbose "Running Test-RestrictCustomScripts for $recnum..."
} }
process { process {
try { try {
# 7.3.4 (L1) Ensure custom script execution is restricted on site collections # 7.3.4 (L1) Ensure custom script execution is restricted on site collections
@@ -30,23 +28,27 @@ function Test-RestrictCustomScripts {
# - Condition A: The `DenyAddAndCustomizePages` setting is not set to `Enabled` for any site collection. # - Condition A: The `DenyAddAndCustomizePages` setting is not set to `Enabled` for any site collection.
# - Condition B: The setting is not validated through PowerShell commands, indicating misconfiguration. # - Condition B: The setting is not validated through PowerShell commands, indicating misconfiguration.
# - Condition C: Verification using the SharePoint Admin Center indicates that the `DenyAddAndCustomizePages` setting is not enforced. # - Condition C: Verification using the SharePoint Admin Center indicates that the `DenyAddAndCustomizePages` setting is not enforced.
# Retrieve all site collections and select necessary properties # Retrieve all site collections and select necessary properties
# $SPOSitesCustomScript Mock Object
<#
$SPOSitesCustomScript = [PSCustomObject]@{
Title = "Site Collection 1"
Url = "https://contoso.sharepoint.com/sites/site1"
DenyAddAndCustomizePages = "Enabled"
}
#>
$SPOSitesCustomScript = Get-CISSpoOutput -Rec $recnum $SPOSitesCustomScript = Get-CISSpoOutput -Rec $recnum
# Process URLs to replace 'sharepoint.com' with '<SPUrl>' # Process URLs to replace 'sharepoint.com' with '<SPUrl>'
$processedUrls = $SPOSitesCustomScript | ForEach-Object { $processedUrls = $SPOSitesCustomScript | ForEach-Object {
$_.Url = $_.Url -replace 'sharepoint\.com', '<SPUrl>' $_.Url = $_.Url -replace 'sharepoint\.com', '<SPUrl>'
$_ $_
} }
# Find sites where custom scripts are allowed # Find sites where custom scripts are allowed
$customScriptAllowedSites = $processedUrls | Where-Object { $_.DenyAddAndCustomizePages -ne 'Enabled' } $customScriptAllowedSites = $processedUrls | Where-Object { $_.DenyAddAndCustomizePages -ne 'Enabled' }
#$verbosePreference = 'Continue' #$verbosePreference = 'Continue'
# Check the total length of URLs # Check the total length of URLs
$totalUrlLength = ($customScriptAllowedSites.Url -join '').Length $totalUrlLength = ($customScriptAllowedSites.Url -join '').Length
Write-Verbose "Total length of URLs: $totalUrlLength" Write-Verbose "Total length of URLs: $totalUrlLength"
# Extract hostnames from allowed sites if the total length exceeds the limit # Extract hostnames from allowed sites if the total length exceeds the limit
$mostUsedHostname = $null $mostUsedHostname = $null
if ($totalUrlLength -gt 20000) { if ($totalUrlLength -gt 20000) {
@@ -57,7 +59,6 @@ function Test-RestrictCustomScripts {
} }
} }
Write-Verbose "Extracted hostnames: $($hostnames -join ', ')" Write-Verbose "Extracted hostnames: $($hostnames -join ', ')"
# Find the most used hostname using the Get-MostCommonWord function # Find the most used hostname using the Get-MostCommonWord function
$mostUsedHostname = Get-MostCommonWord -InputStrings $hostnames $mostUsedHostname = Get-MostCommonWord -InputStrings $hostnames
Write-Verbose "Most used hostname: $mostUsedHostname" Write-Verbose "Most used hostname: $mostUsedHostname"
@@ -65,7 +66,6 @@ function Test-RestrictCustomScripts {
#$verbosePreference = 'SilentlyContinue' #$verbosePreference = 'SilentlyContinue'
# Compliance is true if no sites allow custom scripts # Compliance is true if no sites allow custom scripts
$complianceResult = $customScriptAllowedSites.Count -eq 0 $complianceResult = $customScriptAllowedSites.Count -eq 0
# Gather details for non-compliant sites (where custom scripts are allowed) # Gather details for non-compliant sites (where custom scripts are allowed)
$nonCompliantSiteDetails = $customScriptAllowedSites | ForEach-Object { $nonCompliantSiteDetails = $customScriptAllowedSites | ForEach-Object {
$url = $_.Url $url = $_.Url
@@ -74,32 +74,29 @@ function Test-RestrictCustomScripts {
} }
"$(if ($_.Title) {$_.Title} else {"NoTitle"})|$url" "$(if ($_.Title) {$_.Title} else {"NoTitle"})|$url"
} }
# Prepare failure reasons and details based on compliance # Prepare failure reasons and details based on compliance
$failureReasons = if (-not $complianceResult) { $failureReasons = if (-not $complianceResult) {
"Some site collections are not restricting custom script execution. Review Details property for sites that are not aligned with the benchmark." "Some site collections are not restricting custom script execution. Review Details property for sites that are not aligned with the benchmark.`n" + `
"To remediate this setting, use the following command:`n" + `
"Set-SPOSite -Identity <SiteUrl> -DenyAddAndCustomizePages `$true"
} }
else { else {
"N/A" "N/A"
} }
$details = if ($complianceResult) { $details = if ($complianceResult) {
"All site collections have custom script execution restricted" "All site collections have custom script execution restricted"
} }
else { else {
"Title|Url`n" + ($nonCompliantSiteDetails -join "`n") "Title|Url`n" + ($nonCompliantSiteDetails -join "`n")
} }
# Convert details to PSObject and check length # Convert details to PSObject and check length
$detailsPSObject = $details | ConvertFrom-Csv -Delimiter '|' $detailsPSObject = $details | ConvertFrom-Csv -Delimiter '|'
$detailsLength = ($detailsPSObject | ForEach-Object { $_.Url }).Length $detailsLength = ($detailsPSObject | ForEach-Object { $_.Url }).Length
if ($detailsLength -gt 32767) { if ($detailsLength -gt 32767) {
# Create a preview of the first 10 results # Create a preview of the first 10 results
$preview = $detailsPSObject | Select-Object -First 10 | ForEach-Object { "$($_.Title)|$($_.Url)" } $preview = $detailsPSObject | Select-Object -First 10 | ForEach-Object { "$($_.Title)|$($_.Url)" }
$details = "The output is too large. Here is a preview of the first 10 results:`n`n" + ($preview -join "`n") + "`n`nPlease run the test with the following commands to get the full details:`n`nGet-SPOSite -Limit All | Where-Object { `$.DenyAddAndCustomizePages -ne 'Enabled' } | Select-Object Title, Url" $details = "The output is too large. Here is a preview of the first 10 results:`n`n" + ($preview -join "`n") + "`n`nPlease run the test with the following commands to get the full details:`n`nGet-SPOSite -Limit All | Where-Object { `$.DenyAddAndCustomizePages -ne 'Enabled' } | Select-Object Title, Url"
} }
# Create and populate the CISAuditResult object # Create and populate the CISAuditResult object
$params = @{ $params = @{
Rec = $recnum Rec = $recnum

View File

@@ -5,18 +5,15 @@ function Test-RestrictExternalSharing {
# Aligned # Aligned
# Define your parameters here # Define your parameters here
) )
begin { begin {
<# <#
Conditions for 7.2.3 (L1) Ensure external content sharing is restricted Conditions for 7.2.3 (L1) Ensure external content sharing is restricted
Validate test for a pass: Validate test for a pass:
- Confirm that the automated test results align with the manual audit steps outlined in the CIS benchmark. - Confirm that the automated test results align with the manual audit steps outlined in the CIS benchmark.
- Specific conditions to check: - Specific conditions to check:
- Condition A: The SharingCapability is set to "ExternalUserSharingOnly" or more restrictive in the SharePoint admin center. - Condition A: The SharingCapability is set to "ExternalUserSharingOnly" or more restrictive in the SharePoint admin center.
- Condition B: Using PowerShell, the SharingCapability property for the SharePoint tenant is set to "ExternalUserSharingOnly", "ExistingExternalUserSharingOnly", or "Disabled". - Condition B: Using PowerShell, the SharingCapability property for the SharePoint tenant is set to "ExternalUserSharingOnly", "ExistingExternalUserSharingOnly", or "Disabled".
- Condition C: The external sharing settings in SharePoint Online and OneDrive are set to the same or a more restrictive level than the organizations sharing settings. - Condition C: The external sharing settings in SharePoint Online and OneDrive are set to the same or a more restrictive level than the organizations sharing settings.
Validate test for a fail: Validate test for a fail:
- Confirm that the failure conditions in the automated test are consistent with the manual audit results. - Confirm that the failure conditions in the automated test are consistent with the manual audit results.
- Specific conditions to check: - Specific conditions to check:
@@ -24,34 +21,37 @@ function Test-RestrictExternalSharing {
- Condition B: Using PowerShell, the SharingCapability property for the SharePoint tenant is set to "Anyone" or "ExternalUserAndGuestSharing". - Condition B: Using PowerShell, the SharingCapability property for the SharePoint tenant is set to "Anyone" or "ExternalUserAndGuestSharing".
- Condition C: The external sharing settings in SharePoint Online and OneDrive are set to a more permissive level than the organizations sharing settings. - Condition C: The external sharing settings in SharePoint Online and OneDrive are set to a more permissive level than the organizations sharing settings.
#> #>
# Dot source the class script if necessary # Dot source the class script if necessary
#. .\source\Classes\CISAuditResult.ps1 #. .\source\Classes\CISAuditResult.ps1
# Initialization code, if needed # Initialization code, if needed
$recnum = "7.2.3" $recnum = "7.2.3"
Write-Verbose "Running Test-RestrictExternalSharing for $recnum..."
} }
process { process {
try { try {
# 7.2.3 (L1) Ensure external content sharing is restricted # 7.2.3 (L1) Ensure external content sharing is restricted
# Retrieve the SharingCapability setting for the SharePoint tenant # Retrieve the SharingCapability setting for the SharePoint tenant
<#
$SPOTenantSharingCapability = [PSCustomObject]@{
SharingCapability = "ExternalUserAndGuestSharing"
}
#>
$SPOTenantSharingCapability = Get-CISSpoOutput -Rec $recnum $SPOTenantSharingCapability = Get-CISSpoOutput -Rec $recnum
$isRestricted = $SPOTenantSharingCapability.SharingCapability -in @('ExternalUserSharingOnly', 'ExistingExternalUserSharingOnly', 'Disabled') $isRestricted = $SPOTenantSharingCapability.SharingCapability -in @('ExternalUserSharingOnly', 'ExistingExternalUserSharingOnly', 'Disabled')
# Prepare failure reasons and details based on compliance # Prepare failure reasons and details based on compliance
# Condition B: Using PowerShell, the SharingCapability property for the SharePoint tenant is set to "ExternalUserSharingOnly", "ExistingExternalUserSharingOnly", or "Disabled". # Condition B: Using PowerShell, the SharingCapability property for the SharePoint tenant is set to "ExternalUserSharingOnly", "ExistingExternalUserSharingOnly", or "Disabled".
$failureReasons = if (-not $isRestricted) { $failureReasons = if (-not $isRestricted) {
"External content sharing is not adequately restricted. Current setting: $($SPOTenantSharingCapability.SharingCapability)" "External content sharing is not adequately restricted. Current setting: $($SPOTenantSharingCapability.SharingCapability)`n" + `
"The acceptable values for SharingCapability are: 'ExternalUserSharingOnly', 'ExistingExternalUserSharingOnly', or 'Disabled'.`n" + `
"To remediate this setting, use the Set-SPOTenant cmdlet to set the SharingCapability property to an acceptable value:`n`n" + `
"Set-SPOTenant -SharingCapability <acceptable value from above>"
} }
else { else {
"N/A" "N/A"
} }
# Condition A: The SharingCapability is set to "ExternalUserSharingOnly" or more restrictive in the SharePoint admin center. # Condition A: The SharingCapability is set to "ExternalUserSharingOnly" or more restrictive in the SharePoint admin center.
# Condition C: The external sharing settings in SharePoint Online and OneDrive are set to the same or a more restrictive level than the organizations sharing settings. # Condition C: The external sharing settings in SharePoint Online and OneDrive are set to the same or a more restrictive level than the organizations sharing settings.
$details = "SharingCapability: $($SPOTenantSharingCapability.SharingCapability)" $details = "SharingCapability: $($SPOTenantSharingCapability.SharingCapability)"
# Create and populate the CISAuditResult object # Create and populate the CISAuditResult object
$params = @{ $params = @{
Rec = $recnum Rec = $recnum
@@ -67,7 +67,6 @@ function Test-RestrictExternalSharing {
$auditResult = Get-TestError -LastError $LastError -recnum $recnum $auditResult = Get-TestError -LastError $LastError -recnum $recnum
} }
} }
end { end {
# Return auditResult # Return auditResult
return $auditResult return $auditResult

View File

@@ -5,23 +5,19 @@ function Test-RestrictTenantCreation {
# Aligned # Aligned
# Parameters can be added if needed # Parameters can be added if needed
) )
begin { begin {
# Dot source the class script if necessary # Dot source the class script if necessary
#. .\source\Classes\CISAuditResult.ps1 #. .\source\Classes\CISAuditResult.ps1
# Initialization code, if needed # Initialization code, if needed
$recnum = "5.1.2.3" $recnum = "5.1.2.3"
Write-Verbose "Starting Test-RestrictTenantCreation with Rec: $recnum"
<# <#
Conditions for 5.1.2.3 (L1) Ensure 'Restrict non-admin users from creating tenants' is set to 'Yes' Conditions for 5.1.2.3 (L1) Ensure 'Restrict non-admin users from creating tenants' is set to 'Yes'
Validate test for a pass: Validate test for a pass:
- Confirm that the automated test results align with the manual audit steps outlined in the CIS benchmark. - Confirm that the automated test results align with the manual audit steps outlined in the CIS benchmark.
- Specific conditions to check: - Specific conditions to check:
- Condition A: Restrict non-admin users from creating tenants is set to 'Yes' in the Azure AD and Entra administration portal. - Condition A: Restrict non-admin users from creating tenants is set to 'Yes' in the Azure AD and Entra administration portal.
- Condition B: Using PowerShell, the setting for restricting non-admin users from creating tenants is set to 'Yes'. - Condition B: Using PowerShell, the setting for restricting non-admin users from creating tenants is set to 'Yes'.
Validate test for a fail: Validate test for a fail:
- Confirm that the failure conditions in the automated test are consistent with the manual audit results. - Confirm that the failure conditions in the automated test are consistent with the manual audit results.
- Specific conditions to check: - Specific conditions to check:
@@ -29,15 +25,12 @@ function Test-RestrictTenantCreation {
- Condition B: Using PowerShell, the setting for restricting non-admin users from creating tenants is not set to 'Yes'. - Condition B: Using PowerShell, the setting for restricting non-admin users from creating tenants is not set to 'Yes'.
#> #>
} }
process { process {
try { try {
# 5.1.2.3 (L1) Ensure 'Restrict non-admin users from creating tenants' is set to 'Yes' # 5.1.2.3 (L1) Ensure 'Restrict non-admin users from creating tenants' is set to 'Yes'
# Retrieve the tenant creation policy # Retrieve the tenant creation policy
$tenantCreationPolicy = Get-CISMgOutput -Rec $recnum $tenantCreationPolicy = Get-CISMgOutput -Rec $recnum
$tenantCreationResult = -not $tenantCreationPolicy.AllowedToCreateTenants $tenantCreationResult = -not $tenantCreationPolicy.AllowedToCreateTenants
# Prepare failure reasons and details based on compliance # Prepare failure reasons and details based on compliance
$failureReasons = if ($tenantCreationResult) { $failureReasons = if ($tenantCreationResult) {
"N/A" "N/A"
@@ -45,9 +38,7 @@ function Test-RestrictTenantCreation {
else { else {
"Non-admin users can create tenants" "Non-admin users can create tenants"
} }
$details = "AllowedToCreateTenants: $($tenantCreationPolicy.AllowedToCreateTenants)" $details = "AllowedToCreateTenants: $($tenantCreationPolicy.AllowedToCreateTenants)"
# Create and populate the CISAuditResult object # Create and populate the CISAuditResult object
$params = @{ $params = @{
Rec = $recnum Rec = $recnum
@@ -63,7 +54,6 @@ function Test-RestrictTenantCreation {
$auditResult = Get-TestError -LastError $LastError -recnum $recnum $auditResult = Get-TestError -LastError $LastError -recnum $recnum
} }
} }
end { end {
# Return the audit result # Return the audit result
return $auditResult return $auditResult

View File

@@ -1,19 +1,22 @@
function Test-SafeAttachmentsPolicy { function Test-SafeAttachmentsPolicy {
[CmdletBinding()] [CmdletBinding()]
[OutputType([CISAuditResult])] [OutputType([CISAuditResult])]
param () param (
[Parameter(Mandatory = $false)]
[string]$DomainName
)
begin { begin {
$recnum = "2.1.4" $recnum = "2.1.4"
Write-Verbose "Running Test-SafeAttachmentsPolicy for $recnum..." Write-Verbose "Running Test-SafeAttachmentsPolicy for $recnum..."
<# <#
Conditions for 2.1.4 (L2) Ensure Safe Attachments policy is enabled: Conditions for 2.1.4 (L2) Ensure Safe Attachments policy is enabled:
Validate test for a pass: Validate test for a pass:
- Ensure the highest priority Safe Attachments policy is enabled. - Ensure Safe Attachments policies are enabled.
- Check if the policy's action is set to 'Block'. - Check if each policy's action is set to 'Block'.
- Confirm the QuarantineTag is set to 'AdminOnlyAccessPolicy'. - Confirm the QuarantineTag is set to 'AdminOnlyAccessPolicy'.
- Verify that the Redirect setting is disabled. - Verify that the Redirect setting is disabled.
Validate test for a fail: Validate test for a fail:
- If the highest priority Safe Attachments policy's action is not set to 'Block'. - If any Safe Attachments policy's action is not set to 'Block'.
- If the QuarantineTag is not set to 'AdminOnlyAccessPolicy'. - If the QuarantineTag is not set to 'AdminOnlyAccessPolicy'.
- If the Redirect setting is enabled. - If the Redirect setting is enabled.
- If no enabled Safe Attachments policies are found. - If no enabled Safe Attachments policies are found.
@@ -33,35 +36,47 @@ function Test-SafeAttachmentsPolicy {
} }
) )
#> #>
$safeAttachmentPolicies = Get-CISExoOutput -Rec $recnum $safeAttachmentPolicies, $safeAttachmentRules = Get-CISExoOutput -Rec $recnum
$safeAttachmentPolicies = $safeAttachmentPolicies | Where-Object { $_.Identity -in $safeAttachmentRules.SafeAttachmentPolicy }
if ($safeAttachmentPolicies -ne 1) { if ($safeAttachmentPolicies -ne 1) {
try { try {
$highestPriorityPolicy = $safeAttachmentPolicies | Select-Object -First 1 if ($DomainName) {
$safeAttachmentPolicies = $safeAttachmentPolicies | Where-Object { $_.Identity -eq ($safeAttachmentRules | Sort-Object -Property Priority | Where-Object { $_.RecipientDomainIs -in $DomainName } | Select-Object -ExpandProperty SafeAttachmentPolicy -First 1) }
$RecipientDomains = $safeAttachmentRules | Where-Object { $_.SafeAttachmentPolicy -eq $safeAttachmentPolicies.Identity } | Select-Object -ExpandProperty RecipientDomainIs
}
# Initialize details and failure reasons # Initialize details and failure reasons
$details = @() $details = @()
$failureReasons = @() $failureReasons = @()
foreach ($policy in $safeAttachmentPolicies) {
# Check policy specifics as per CIS benchmark requirements # Check policy specifics as per CIS benchmark requirements
if ($highestPriorityPolicy.Action -ne 'Block') { if ($Policy.Action -ne 'Block') {
$failureReasons += "Policy action is not set to 'Block'." $failureReasons += "Policy: $($Policy.Identity); Action is not set to 'Block'."
} }
if ($highestPriorityPolicy.QuarantineTag -ne 'AdminOnlyAccessPolicy') { if ($Policy.QuarantineTag -ne 'AdminOnlyAccessPolicy') {
$failureReasons += "Quarantine policy is not set to 'AdminOnlyAccessPolicy'." $failureReasons += "Policy: $($Policy.Identity); Quarantine is not set to 'AdminOnlyAccessPolicy'."
} }
if ($highestPriorityPolicy.Redirect -ne $false) { if ($Policy.Redirect -ne $false) {
$failureReasons += "Redirect is not disabled." $failureReasons += "Policy: $($Policy.Identity); Redirect is not disabled."
} }
# The result is a pass if there are no failure reasons # The result is a pass if there are no failure reasons
$details += [PSCustomObject]@{
Policy = ($Policy.Identity).trim()
Action = $Policy.Action
QuarantineTag = $Policy.QuarantineTag
Redirect = $Policy.Redirect
Enabled = $Policy.Enable
Priority = [int]($safeAttachmentRules | Where-Object { $_.SafeAttachmentPolicy -eq $Policy.Identity } | Select-Object -ExpandProperty Priority)
}
}
$result = $failureReasons.Count -eq 0 $result = $failureReasons.Count -eq 0
$details = [PSCustomObject]@{ if ($RecipientDomains) {
Policy = $highestPriorityPolicy.Identity $failureReasons += "Recipient domain(s): '$($RecipientDomains -join ', ' )' included in tested policy."
Action = $highestPriorityPolicy.Action
QuarantineTag = $highestPriorityPolicy.QuarantineTag
Redirect = $highestPriorityPolicy.Redirect
Enabled = $highestPriorityPolicy.Enable
} }
# Format details for output manually # Format details for output manually
$detailsString = "Policy|Action|QuarantineTag|Redirect|Enabled`n" + ($details | $detailsString = "Policy|Action|QuarantineTag|Redirect|Enabled|Priority`n" + `
ForEach-Object { "$($_.Policy)|$($_.Action)|$($_.QuarantineTag)|$($_.Redirect)|$($_.Enabled)`n" } ($details | ForEach-Object {
"$($_.Policy)|$($_.Action)|$($_.QuarantineTag)|$($_.Redirect)|$($_.Enabled)|$($_.Priority)`n"
}
) )
$failureReasonsString = ($failureReasons -join "`n") $failureReasonsString = ($failureReasons -join "`n")
# Create and populate the CISAuditResult object # Create and populate the CISAuditResult object
@@ -75,7 +90,7 @@ function Test-SafeAttachmentsPolicy {
$auditResult = Initialize-CISAuditResult @params $auditResult = Initialize-CISAuditResult @params
} }
catch { catch {
Write-Error "An error occurred during the test: $_" Write-Error "An error occurred during the test $recnum`:: $_"
# Retrieve the description from the test definitions # Retrieve the description from the test definitions
$testDefinition = $script:TestDefinitionsObject | Where-Object { $_.Rec -eq $recnum } $testDefinition = $script:TestDefinitionsObject | Where-Object { $_.Rec -eq $recnum }
$description = if ($testDefinition) { $testDefinition.RecDescription } else { "Description not found" } $description = if ($testDefinition) { $testDefinition.RecDescription } else { "Description not found" }

View File

@@ -88,7 +88,7 @@ AllowSafeDocsOpen: $($_.AllowSafeDocsOpen)
$auditResult = Initialize-CISAuditResult @params $auditResult = Initialize-CISAuditResult @params
} }
catch { catch {
Write-Error "An error occurred during the test: $_" Write-Error "An error occurred during the test $recnum`:: $_"
# Retrieve the description from the test definitions # Retrieve the description from the test definitions
$testDefinition = $script:TestDefinitionsObject | Where-Object { $_.Rec -eq $recnum } $testDefinition = $script:TestDefinitionsObject | Where-Object { $_.Rec -eq $recnum }
$description = if ($testDefinition) { $testDefinition.RecDescription } else { "Description not found" } $description = if ($testDefinition) { $testDefinition.RecDescription } else { "Description not found" }

View File

@@ -58,7 +58,7 @@ function Test-SafeLinksOfficeApps {
$auditResult = Initialize-CISAuditResult @params $auditResult = Initialize-CISAuditResult @params
} }
catch { catch {
Write-Error "An error occurred during the test: $_" Write-Error "An error occurred during the test $recnum`:: $_"
# Retrieve the description from the test definitions # Retrieve the description from the test definitions
$testDefinition = $script:TestDefinitionsObject | Where-Object { $_.Rec -eq $recnum } $testDefinition = $script:TestDefinitionsObject | Where-Object { $_.Rec -eq $recnum }
$description = if ($testDefinition) { $testDefinition.RecDescription } else { "Description not found" } $description = if ($testDefinition) { $testDefinition.RecDescription } else { "Description not found" }

View File

@@ -5,7 +5,6 @@ function Test-SharePointAADB2B {
# Aligned # Aligned
# Define your parameters here # Define your parameters here
) )
begin { begin {
# Conditions for 7.2.2 (L1) Ensure SharePoint and OneDrive integration with Azure AD B2B is enabled # Conditions for 7.2.2 (L1) Ensure SharePoint and OneDrive integration with Azure AD B2B is enabled
# #
@@ -22,26 +21,29 @@ function Test-SharePointAADB2B {
# - Condition A: The `EnableAzureADB2BIntegration` property is set to `False` for the SharePoint tenant. # - Condition A: The `EnableAzureADB2BIntegration` property is set to `False` for the SharePoint tenant.
# - Condition B: The integration between SharePoint, OneDrive, and Azure AD B2B is not active. # - Condition B: The integration between SharePoint, OneDrive, and Azure AD B2B is not active.
# - Condition C: Guest accounts are not managed in Azure AD and are not subject to access policies. # - Condition C: Guest accounts are not managed in Azure AD and are not subject to access policies.
# Dot source the class script if necessary # Dot source the class script if necessary
#. .\source\Classes\CISAuditResult.ps1 #. .\source\Classes\CISAuditResult.ps1
# Initialization code, if needed # Initialization code, if needed
$recnum = "7.2.2" $recnum = "7.2.2"
Write-Verbose "Running Test-SharePointAADB2B for $recnum..."
} }
process { process {
try { try {
# 7.2.2 (L1) Ensure SharePoint and OneDrive integration with Azure AD B2B is enabled # 7.2.2 (L1) Ensure SharePoint and OneDrive integration with Azure AD B2B is enabled
# $SPOTenantAzureADB2B Mock Object
<#
$SPOTenantAzureADB2B = [PSCustomObject]@{
EnableAzureADB2BIntegration = $false
}
#>
$SPOTenantAzureADB2B = Get-CISSpoOutput -Rec $recnum $SPOTenantAzureADB2B = Get-CISSpoOutput -Rec $recnum
# Populate the auditResult object with the required properties # Populate the auditResult object with the required properties
$params = @{ $params = @{
Rec = $recnum Rec = $recnum
Result = $SPOTenantAzureADB2B.EnableAzureADB2BIntegration Result = $SPOTenantAzureADB2B.EnableAzureADB2BIntegration
Status = if ($SPOTenantAzureADB2B.EnableAzureADB2BIntegration) { "Pass" } else { "Fail" } Status = if ($SPOTenantAzureADB2B.EnableAzureADB2BIntegration) { "Pass" } else { "Fail" }
Details = "EnableAzureADB2BIntegration: $($SPOTenantAzureADB2B.EnableAzureADB2BIntegration)" Details = "EnableAzureADB2BIntegration: $($SPOTenantAzureADB2B.EnableAzureADB2BIntegration)"
FailureReason = if (-not $SPOTenantAzureADB2B.EnableAzureADB2BIntegration) { "Azure AD B2B integration is not enabled" } else { "N/A" } FailureReason = if (-not $SPOTenantAzureADB2B.EnableAzureADB2BIntegration) { "Azure AD B2B integration is not enabled. The following command can be used to enable:`nSet-SPOTenant -EnableAzureADB2BIntegration `$true" } else { "N/A" }
} }
$auditResult = Initialize-CISAuditResult @params $auditResult = Initialize-CISAuditResult @params
} }
@@ -50,7 +52,6 @@ function Test-SharePointAADB2B {
$auditResult = Get-TestError -LastError $LastError -recnum $recnum $auditResult = Get-TestError -LastError $LastError -recnum $recnum
} }
} }
end { end {
# Return auditResult # Return auditResult
return $auditResult return $auditResult

View File

@@ -5,14 +5,12 @@ function Test-SharePointExternalSharingDomains {
# Aligned # Aligned
# Define your parameters here # Define your parameters here
) )
begin { begin {
# Dot source the class script if necessary # Dot source the class script if necessary
#. .\source\Classes\CISAuditResult.ps1 #. .\source\Classes\CISAuditResult.ps1
# Initialization code, if needed # Initialization code, if needed
$recnum = "7.2.6" $recnum = "7.2.6"
Write-Verbose "Running Test-SharePointExternalSharingDomains for $recnum..."
# Conditions for 7.2.6 (L2) Ensure SharePoint external sharing is managed through domain whitelist/blacklists # Conditions for 7.2.6 (L2) Ensure SharePoint external sharing is managed through domain whitelist/blacklists
# #
# Validate test for a pass: # Validate test for a pass:
@@ -29,13 +27,18 @@ function Test-SharePointExternalSharingDomains {
# - Condition B: The "SharingDomainRestrictionMode" is not set to "AllowList" using PowerShell. # - Condition B: The "SharingDomainRestrictionMode" is not set to "AllowList" using PowerShell.
# - Condition C: The "SharingAllowedDomainList" does not contain the domains trusted by the organization for external sharing. # - Condition C: The "SharingAllowedDomainList" does not contain the domains trusted by the organization for external sharing.
} }
process { process {
try { try {
# 7.2.6 (L2) Ensure SharePoint external sharing is managed through domain whitelist/blacklists # 7.2.6 (L2) Ensure SharePoint external sharing is managed through domain whitelist/blacklists
$SPOTenant = Get-CISSpoOutput -Rec $recnum $SPOTenant = Get-CISSpoOutput -Rec $recnum
# $SPOTenant Mock Object
<#
$SPOTenant = [PSCustomObject]@{
SharingDomainRestrictionMode = "AllowList"
SharingAllowedDomainList = "domain1.com", "domain2.com"
}
#>
$isDomainRestrictionConfigured = $SPOTenant.SharingDomainRestrictionMode -eq 'AllowList' $isDomainRestrictionConfigured = $SPOTenant.SharingDomainRestrictionMode -eq 'AllowList'
# Populate the auditResult object with the required properties # Populate the auditResult object with the required properties
$params = @{ $params = @{
Rec = $recnum Rec = $recnum
@@ -51,7 +54,6 @@ function Test-SharePointExternalSharingDomains {
$auditResult = Get-TestError -LastError $LastError -recnum $recnum $auditResult = Get-TestError -LastError $LastError -recnum $recnum
} }
} }
end { end {
# Return auditResult # Return auditResult
return $auditResult return $auditResult

View File

@@ -5,14 +5,12 @@ function Test-SharePointGuestsItemSharing {
# Aligned # Aligned
# Define your parameters here # Define your parameters here
) )
begin { begin {
# Dot source the class script if necessary # Dot source the class script if necessary
#. .\source\Classes\CISAuditResult.ps1 #. .\source\Classes\CISAuditResult.ps1
# Initialization code, if needed # Initialization code, if needed
$recnum = "7.2.5" $recnum = "7.2.5"
Write-Verbose "Running Test-SharePointGuestsItemSharing for $recnum..."
# Conditions for 7.2.5 (L2) Ensure that SharePoint guest users cannot share items they don't own # Conditions for 7.2.5 (L2) Ensure that SharePoint guest users cannot share items they don't own
# #
# Validate test for a pass: # Validate test for a pass:
@@ -29,20 +27,24 @@ function Test-SharePointGuestsItemSharing {
# - Condition B: The SharePoint admin center setting "Allow guests to share items they don't own" is checked. # - Condition B: The SharePoint admin center setting "Allow guests to share items they don't own" is checked.
# - Condition C: Ensure that external users can re-share items they don't own. # - Condition C: Ensure that external users can re-share items they don't own.
} }
process { process {
try { try {
# 7.2.5 (L2) Ensure that SharePoint guest users cannot share items they don't own # 7.2.5 (L2) Ensure that SharePoint guest users cannot share items they don't own
# $SPOTenant Mock Object
<#
$SPOTenant = [PSCustomObject]@{
PreventExternalUsersFromResharing = $false
}
#>
$SPOTenant = Get-CISSpoOutput -Rec $recnum $SPOTenant = Get-CISSpoOutput -Rec $recnum
$isGuestResharingPrevented = $SPOTenant.PreventExternalUsersFromResharing $isGuestResharingPrevented = $SPOTenant.PreventExternalUsersFromResharing
# Populate the auditResult object with the required properties # Populate the auditResult object with the required properties
$params = @{ $params = @{
Rec = $recnum Rec = $recnum
Result = $isGuestResharingPrevented Result = $isGuestResharingPrevented
Status = if ($isGuestResharingPrevented) { "Pass" } else { "Fail" } Status = if ($isGuestResharingPrevented) { "Pass" } else { "Fail" }
Details = "PreventExternalUsersFromResharing: $isGuestResharingPrevented" Details = "PreventExternalUsersFromResharing: $isGuestResharingPrevented"
FailureReason = if (-not $isGuestResharingPrevented) { "Guest users can reshare items they don't own." } else { "N/A" } FailureReason = if (-not $isGuestResharingPrevented) { "Guest users can reshare items they don't own. To prevent external users from resharing content they don't own,`nuse the following command:`nSet-SPOTenant -PreventExternalUsersFromResharing `$True" } else { "N/A" }
} }
$auditResult = Initialize-CISAuditResult @params $auditResult = Initialize-CISAuditResult @params
} }
@@ -51,7 +53,6 @@ function Test-SharePointGuestsItemSharing {
$auditResult = Get-TestError -LastError $LastError -recnum $recnum $auditResult = Get-TestError -LastError $LastError -recnum $recnum
} }
} }
end { end {
# Return auditResult # Return auditResult
return $auditResult return $auditResult

View File

@@ -108,7 +108,7 @@ function Test-SpamPolicyAdminNotify {
$auditResult = Initialize-CISAuditResult @params $auditResult = Initialize-CISAuditResult @params
} }
catch { catch {
Write-Error "An error occurred during the test: $_" Write-Error "An error occurred during the test $recnum`:: $_"
$auditResult = Get-TestError -LastError $_ -recnum $recnum $auditResult = Get-TestError -LastError $_ -recnum $recnum
} }
} }

View File

@@ -0,0 +1,27 @@
$ProjectPath = "$PSScriptRoot\..\..\.." | Convert-Path
$ProjectName = ((Get-ChildItem -Path $ProjectPath\*\*.psd1).Where{
($_.Directory.Name -match 'source|src' -or $_.Directory.Name -eq $_.BaseName) -and
$(try { Test-ModuleManifest $_.FullName -ErrorAction Stop } catch { $false } )
}).BaseName
Import-Module $ProjectName
InModuleScope $ProjectName {
Describe Get-PrivateFunction {
Context 'Default' {
BeforeEach {
$return = Get-PrivateFunction -PrivateData 'string'
}
It 'Returns a single object' {
($return | Measure-Object).Count | Should -Be 1
}
It 'Returns a string based on the parameter PrivateData' {
$return | Should -Be 'string'
}
}
}
}