Created
January 9, 2019 15:38
-
-
Save poiriersimon/5507d0fd46284fa68b1e10d7c340c8df to your computer and use it in GitHub Desktop.
O365 Check for user that doesn't have password Expiration and aren't using Strong Password
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#1 - List Managed Domain | |
$ManagedDomain = Get-MSOLDomain |where {$_.AuthenticationType -eq "Managed"} | |
#2 - Check if 1 users exist in those domain | |
$UsedManagedDomains = @() | |
foreach ($ManagedDomain in $ManagedDomains){$Users = @(); $users= Get-MSOLUser -All | where {$_.UserPrincipalName -like "*$($ManagedDomain.name)"}} | |
#3 - for each of those domain - Get-MSOLUser | where{$_.PasswordNeverExpire -eq $TRUE} | |
[array]$UnsafeUsers = $Users | where {$_.PasswordNeverExpires -eq $True -and StrongPasswordRequired -eq $False} | |
#4 - if any Trigger | |
If($UnsafeUsers.count -eq 0){Write-host "Pass"} Else {Write-host "Fail : You have $($UnsafeUsers.count) account"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment