mirror of
https://github.com/admindroid-community/powershell-scripts.git
synced 2025-12-17 16:35:19 +00:00
Update GetMFAStatus.ps1
Added Admin roles
This commit is contained in:
parent
155d1d332b
commit
89606dff94
@ -47,6 +47,7 @@ Get-MsolUser -All | foreach{
|
|||||||
$Upn=$_.UserPrincipalName
|
$Upn=$_.UserPrincipalName
|
||||||
$MFAStatus=$_.StrongAuthenticationRequirements.State
|
$MFAStatus=$_.StrongAuthenticationRequirements.State
|
||||||
$MethodTypes=$_.StrongAuthenticationMethods
|
$MethodTypes=$_.StrongAuthenticationMethods
|
||||||
|
$RolesAssigned=""
|
||||||
Write-Progress -Activity "`n Processed user count: $UserCount "`n" Currently Processing: $DisplayName"
|
Write-Progress -Activity "`n Processed user count: $UserCount "`n" Currently Processing: $DisplayName"
|
||||||
if($_.BlockCredential -eq "True")
|
if($_.BlockCredential -eq "True")
|
||||||
{
|
{
|
||||||
@ -73,11 +74,20 @@ Get-MsolUser -All | foreach{
|
|||||||
$Roles=(Get-MsolUserRole -UserPrincipalName $upn).Name
|
$Roles=(Get-MsolUserRole -UserPrincipalName $upn).Name
|
||||||
if($Roles.count -eq 0)
|
if($Roles.count -eq 0)
|
||||||
{
|
{
|
||||||
|
$RolesAssigned="No roles"
|
||||||
$IsAdmin="False"
|
$IsAdmin="False"
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$IsAdmin="True"
|
$IsAdmin="True"
|
||||||
|
foreach($Role in $Roles)
|
||||||
|
{
|
||||||
|
$RolesAssigned=$RolesAssigned+$Role
|
||||||
|
if($Roles.indexof($role) -lt (($Roles.count)-1))
|
||||||
|
{
|
||||||
|
$RolesAssigned=$RolesAssigned+","
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#Filter result based on Admin users
|
#Filter result based on Admin users
|
||||||
@ -149,23 +159,22 @@ Get-MsolUser -All | foreach{
|
|||||||
|
|
||||||
#Print to output file
|
#Print to output file
|
||||||
$PrintedUser++
|
$PrintedUser++
|
||||||
$Result=@{'DisplayName'=$DisplayName;'UserPrincipalName'=$upn;'MFAStatus'=$MFAStatus;'ActivationStatus'=$ActivationStatus;'DefaultMFAMethod'=$DefaultMFAMethod;'AllMFAMethods'=$Methods;'MFAPhone'=$MFAPhone;'MFAEmail'=$MFAEmail;'LicenseStatus'=$_.IsLicensed;'IsAdmin'=$IsAdmin; 'SignInStatus'=$SigninStatus}
|
$Result=@{'DisplayName'=$DisplayName;'UserPrincipalName'=$upn;'MFAStatus'=$MFAStatus;'ActivationStatus'=$ActivationStatus;'DefaultMFAMethod'=$DefaultMFAMethod;'AllMFAMethods'=$Methods;'MFAPhone'=$MFAPhone;'MFAEmail'=$MFAEmail;'LicenseStatus'=$_.IsLicensed;'IsAdmin'=$IsAdmin;'AdminRoles'=$RolesAssigned;'SignInStatus'=$SigninStatus}
|
||||||
$Results= New-Object PSObject -Property $Result
|
$Results= New-Object PSObject -Property $Result
|
||||||
$Results | Select-Object DisplayName,UserPrincipalName,MFAStatus,ActivationStatus,DefaultMFAMethod,AllMFAMethods,MFAPhone,MFAEmail,LicenseStatus,IsAdmin,SignInStatus | Export-Csv -Path $ExportCSVReport -Notype -Append
|
$Results | Select-Object DisplayName,UserPrincipalName,MFAStatus,ActivationStatus,DefaultMFAMethod,AllMFAMethods,MFAPhone,MFAEmail,LicenseStatus,IsAdmin,AdminRoles,SignInStatus | Export-Csv -Path $ExportCSVReport -Notype -Append
|
||||||
}
|
}
|
||||||
|
|
||||||
#Check for disabled userwe
|
#Check for MFA disabled user
|
||||||
elseif(($DisabledOnly.IsPresent) -and ($MFAStatus -eq $Null) -and ($_.StrongAuthenticationMethods.MethodType -eq $Null))
|
elseif(($DisabledOnly.IsPresent) -and ($MFAStatus -eq $Null) -and ($_.StrongAuthenticationMethods.MethodType -eq $Null))
|
||||||
{
|
{
|
||||||
$MFAStatus="Disabled"
|
$MFAStatus="Disabled"
|
||||||
$Department=$_.Department
|
$Department=$_.Department
|
||||||
if($Department -eq $Null)
|
if($Department -eq $Null)
|
||||||
{ $Department="-"}
|
{ $Department="-"}
|
||||||
write-host Dept $Department
|
|
||||||
$PrintedUser++
|
$PrintedUser++
|
||||||
$Result=@{'DisplayName'=$DisplayName;'UserPrincipalName'=$upn;'Department'=$Department;'MFAStatus'=$MFAStatus;'LicenseStatus'=$_.IsLicensed;'IsAdmin'=$IsAdmin; 'SignInStatus'=$SigninStatus}
|
$Result=@{'DisplayName'=$DisplayName;'UserPrincipalName'=$upn;'Department'=$Department;'MFAStatus'=$MFAStatus;'LicenseStatus'=$_.IsLicensed;'IsAdmin'=$IsAdmin;'AdminRoles'=$RolesAssigned; 'SignInStatus'=$SigninStatus}
|
||||||
$Results= New-Object PSObject -Property $Result
|
$Results= New-Object PSObject -Property $Result
|
||||||
$Results | Select-Object DisplayName,UserPrincipalName,Department,MFAStatus,LicenseStatus,IsAdmin,SignInStatus | Export-Csv -Path $ExportCSV -Notype -Append
|
$Results | Select-Object DisplayName,UserPrincipalName,Department,MFAStatus,LicenseStatus,IsAdmin,AdminRoles,SignInStatus | Export-Csv -Path $ExportCSV -Notype -Append
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user