23 lines
598 B
PowerShell
23 lines
598 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 "C:\Temp\PasswordChangeTimeStamp.csv" -NoTypeInformation |