add: Added DoNotConfirmConnections Switch to main function

This commit is contained in:
DrIOS
2024-06-17 13:51:10 -05:00
parent 99933f7655
commit a97eda1662

View File

@@ -27,6 +27,8 @@
If specified, the cmdlet will not disconnect from Microsoft 365 services after execution. If specified, the cmdlet will not disconnect from Microsoft 365 services after execution.
.PARAMETER NoModuleCheck .PARAMETER NoModuleCheck
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
If specified, the cmdlet will not prompt for confirmation before proceeding with established connections and will disconnect from all of them.
.EXAMPLE .EXAMPLE
PS> Invoke-M365SecurityAudit PS> Invoke-M365SecurityAudit
Performs a security audit using default parameters. Performs a security audit using default parameters.
@@ -174,7 +176,8 @@ function Invoke-M365SecurityAudit {
# Common parameters for all parameter sets # Common parameters for all parameter sets
[switch]$DoNotConnect, [switch]$DoNotConnect,
[switch]$DoNotDisconnect, [switch]$DoNotDisconnect,
[switch]$NoModuleCheck [switch]$NoModuleCheck,
[switch]$DoNotConfirmConnections
) )
Begin { Begin {
@@ -244,7 +247,7 @@ function Invoke-M365SecurityAudit {
$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-Information "Establishing connections to Microsoft 365 services: $($actualUniqueConnections -join ', ')" -InformationAction Continue Write-Information "Establishing connections to Microsoft 365 services: $($actualUniqueConnections -join ', ')" -InformationAction Continue
Connect-M365Suite -TenantAdminUrl $TenantAdminUrl -RequiredConnections $requiredConnections Connect-M365Suite -TenantAdminUrl $TenantAdminUrl -RequiredConnections $requiredConnections -SkipConfirmation:$DoNotConfirmConnections
} }
} }
catch { catch {