Required modules for Azure connection should be minimized
When connecting to All or Azure services without the necessary modules being preinstalled the error message is generated too broadly:
if ($Service -contains "Azure" -or $Service -contains "All") {
Write-Verbose "Connecting to Microsoft Azure"
try {
Connect-AzAccount -SkipContextPopulation -UseDeviceAuthentication:$UseDeviceCode -Environment $AzureEnvironment
} catch [Management.Automation.CommandNotFoundException] {
Write-Host "`nThe Azure PowerShell module is not installed. Please install the module using the following command. For more information see https://learn.microsoft.com/powershell/azure/install-azure-powershell" -ForegroundColor Red
Write-Host "`Install-Module Az -Scope CurrentUser`n" -ForegroundColor Yellow
}
}
Do we need the full Azure PowerShell package or only Az.Accounts?
This can be my first issue 😊
Currently, I believe the only the only cmdlet using Azure is https://github.com/maester365/maester/blob/main/powershell/public/cisa/entra/Test-MtCisaDiagnosticSettings.ps1.
That does use Invoke-AzRestMethod. Assuming future cmdlets would use that method rather than the submodules Az.Accounts would be sufficient.
@sassdawe yes please go ahead with a PR. Tx!
It's been 3 months so I put in a PR, hope that's ok.