powershell-scripts/Entra/Get-PasswordExpiryReport.ps1

23 lines
590 B
PowerShell

#Connect to Microsoft Graph
Connect-MgGraph -Scopes "User.Read.All"
#Set the properties to retrieve
$Properties = @(
"id",
"DisplayName",
"userprincipalname",
"PasswordPolicies",
"AccountEnabled",
"UserType",
"OnPremisesSyncEnabled",
"lastPasswordChangeDateTime",
"mail",
"jobtitle",
"department"
)
#Retrieve the password change date timestamp of all users
$AllUsers = Get-MgUser -All -Property $Properties | Select-Object -Property $Properties
#Export to CSV
$AllUsers | Export-Csv -Path "PasswordChangeTimeStamp.csv" -NoTypeInformation