add: skip msol connnection for Get-MFAStatus
This commit is contained in:
@@ -33,7 +33,8 @@ function Get-MFAStatus {
|
|||||||
param (
|
param (
|
||||||
[Parameter(Mandatory = $false)]
|
[Parameter(Mandatory = $false)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]$UserId
|
[string]$UserId,
|
||||||
|
[switch]$SkipMSOLConnectionChecks
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
begin {
|
||||||
@@ -43,7 +44,9 @@ function Get-MFAStatus {
|
|||||||
|
|
||||||
process {
|
process {
|
||||||
if (Get-Module MSOnline){
|
if (Get-Module MSOnline){
|
||||||
Connect-MsolService
|
if (-not $SkipMSOLConnectionChecks) {
|
||||||
|
Connect-MsolService
|
||||||
|
}
|
||||||
Write-Host "Finding Azure Active Directory Accounts..."
|
Write-Host "Finding Azure Active Directory Accounts..."
|
||||||
# Get all users, excluding guests
|
# Get all users, excluding guests
|
||||||
$Users = if ($PSBoundParameters.ContainsKey('UserId')) {
|
$Users = if ($PSBoundParameters.ContainsKey('UserId')) {
|
||||||
@@ -87,13 +90,15 @@ function Get-MFAStatus {
|
|||||||
MFAPhoneNumber = $MFAPhoneNumber
|
MFAPhoneNumber = $MFAPhoneNumber
|
||||||
PrimarySMTP = ($PrimarySMTP -join ',')
|
PrimarySMTP = ($PrimarySMTP -join ',')
|
||||||
Aliases = ($Aliases -join ',')
|
Aliases = ($Aliases -join ',')
|
||||||
|
isLicensed = $User.isLicensed
|
||||||
}
|
}
|
||||||
|
|
||||||
$Report.Add($ReportLine)
|
$Report.Add($ReportLine)
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "Processing complete."
|
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 {
|
else {
|
||||||
Write-Host "You must first install MSOL using:`nInstall-Module MSOnline -Scope CurrentUser -Force"
|
Write-Host "You must first install MSOL using:`nInstall-Module MSOnline -Scope CurrentUser -Force"
|
||||||
|
Reference in New Issue
Block a user