fix: write-host in public function due to code scanning alert

This commit is contained in:
DrIOS
2024-06-14 11:02:51 -05:00
parent 342d0ac4a9
commit 4b3e448e48

View File

@@ -44,7 +44,7 @@ function Get-MFAStatus {
process {
if (Get-Module MSOnline){
Connect-MsolService
Write-Host "Finding Azure Active Directory Accounts..."
Write-Host -Object "Finding Azure Active Directory Accounts..."
# Get all users, excluding guests
$Users = if ($PSBoundParameters.ContainsKey('UserId')) {
Get-MsolUser -UserPrincipalName $UserId
@@ -52,7 +52,7 @@ function Get-MFAStatus {
Get-MsolUser -All | Where-Object { $_.UserType -ne "Guest" }
}
$Report = [System.Collections.Generic.List[Object]]::new() # Create output list
Write-Host "Processing" $Users.Count "accounts..."
Write-Host -Object "Processing" $Users.Count "accounts..."
ForEach ($User in $Users) {
$MFADefaultMethod = ($User.StrongAuthenticationMethods | Where-Object { $_.IsDefault -eq "True" }).MethodType
$MFAPhoneNumber = $User.StrongAuthenticationUserDetails.PhoneNumber
@@ -92,11 +92,11 @@ function Get-MFAStatus {
$Report.Add($ReportLine)
}
Write-Host "Processing complete."
Write-Host -Object "Processing complete."
return $Report | Select-Object UserPrincipalName, DisplayName, MFAState, MFADefaultMethod, MFAPhoneNumber, PrimarySMTP, Aliases | Sort-Object UserPrincipalName
}
else {
Write-Host "You must first install MSOL using:`nInstall-Module MSOnline -Scope CurrentUser -Force"
Write-Host -Object "You must first install MSOL using:`nInstall-Module MSOnline -Scope CurrentUser -Force"
}
}