From f5f6d39c730d83f09a4548dca043c5838b515c52 Mon Sep 17 00:00:00 2001 From: DrIOS <58635327+DrIOSX@users.noreply.github.com> Date: Sun, 23 Jun 2024 10:03:37 -0500 Subject: [PATCH] add: skip msol connnection for Get-MFAStatus --- source/Public/Get-MFAStatus.ps1 | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/source/Public/Get-MFAStatus.ps1 b/source/Public/Get-MFAStatus.ps1 index 53f6112..a073ba9 100644 --- a/source/Public/Get-MFAStatus.ps1 +++ b/source/Public/Get-MFAStatus.ps1 @@ -33,7 +33,8 @@ function Get-MFAStatus { param ( [Parameter(Mandatory = $false)] [ValidateNotNullOrEmpty()] - [string]$UserId + [string]$UserId, + [switch]$SkipMSOLConnectionChecks ) begin { @@ -43,7 +44,9 @@ function Get-MFAStatus { process { if (Get-Module MSOnline){ - Connect-MsolService + if (-not $SkipMSOLConnectionChecks) { + Connect-MsolService + } Write-Host "Finding Azure Active Directory Accounts..." # Get all users, excluding guests $Users = if ($PSBoundParameters.ContainsKey('UserId')) { @@ -87,13 +90,15 @@ function Get-MFAStatus { MFAPhoneNumber = $MFAPhoneNumber PrimarySMTP = ($PrimarySMTP -join ',') Aliases = ($Aliases -join ',') + isLicensed = $User.isLicensed } $Report.Add($ReportLine) } Write-Host "Processing complete." - return $Report | Select-Object UserPrincipalName, DisplayName, MFAState, MFADefaultMethod, MFAPhoneNumber, PrimarySMTP, Aliases | Sort-Object UserPrincipalName + Write-Host "To disconnect from the MsolService close the powershell session or wait for the session to expire." + return $Report | Select-Object UserPrincipalName, DisplayName, MFAState, MFADefaultMethod, MFAPhoneNumber, PrimarySMTP, Aliases, isLicensed | Sort-Object UserPrincipalName } else { Write-Host "You must first install MSOL using:`nInstall-Module MSOnline -Scope CurrentUser -Force"