Advertisement
D0cEvil

PowerShell - Azure Passw Never Expires

Dec 27th, 2022
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PowerShell 0.99 KB | Cybersecurity | 0 0
  1. #MS Azure - Password never expires
  2.  
  3. Connect-AzureAD
  4.  
  5. # For single user
  6.  
  7. Get-AzureADUser -ObjectId userUPN@contoso.com | Select-Object UserprincipalName,@{
  8.     N="PasswordNeverExpires";E={$_.PasswordPolicies -contains "DisablePasswordExpiration"}
  9. }
  10.  
  11. # For all users
  12.  
  13. Get-AzureADUser -All $true | Select-Object UserprincipalName,@{
  14.     N="PasswordNeverExpires";E={$_.PasswordPolicies -contains "DisablePasswordExpiration"}
  15.  }
  16.  
  17. # For all users, log to html
  18.  
  19. Get-AzureADUser -All $true | Select-Object UserprincipalName,@{
  20.     N="PasswordNeverExpires";E={$_.PasswordPolicies -contains "DisablePasswordExpiration"}
  21. } | ConvertTo-Html | Out-File $env:userprofile\Desktop\ReportPasswordNeverExpires.html
  22.  
  23. # For all users, Log to csv
  24.  
  25. Get-AzureADUser -All $true | Select-Object UserprincipalName,@{
  26.     N="PasswordNeverExpires";E={$_.PasswordPolicies -contains "DisablePasswordExpiration"}
  27. } | ConvertTo-Csv -NoTypeInformation | Out-File $env:userprofile\Desktop\ReportPasswordNeverExpires.csv
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement