forked from jjmolerof/PowerShellScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGet-MsolADPasswordReport.ps1
More file actions
33 lines (32 loc) · 1.56 KB
/
Copy pathGet-MsolADPasswordReport.ps1
File metadata and controls
33 lines (32 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
$Users = Get-MsolUser | where {$_.LastDirSyncTime -and $_.UserPrincipalName -notlike "Sync_*"} | select UserPrincipalName,ImmutableID,BlockCredential,LastPasswordChangeTimestamp,LastDirSyncTime
foreach ($User in $Users)
{
$ADUser = @()
$ADUser = Get-AdUser ([GUID]([system.convert]::frombase64string($User.ImmutableID))) -Properties PasswordLastSet
if ($ADUser)
{
$Properties = @{
"MSOL_User"=$User.UserPrincipalName
"MSOL_LastPasswordChangeTimestamp"=$User.LastPasswordChangeTimestamp
"MSOL_BlockCredential"=$User.BlockCredential
"MSOL_LastDirSyncTime"=$User.LastDirSyncTime
"AD_User"=$ADUser.UserPrincipalName
"AD_User_Enabled"=$ADUser.Enabled
"AD_PasswordLastSet"=$ADUser.PasswordLastSet}
$Obj = New-Object -TypeName PSObject -Property $Properties
Write-Output $Obj | select MSOL_User,MSOL_LastPasswordChangeTimestamp,MSOL_BlockCredential,MSOL_LastDirSyncTime,AD_User,AD_User_Enabled,AD_PasswordLastSet
}
else
{
$Properties = @{
"MSOL_User"=$User.UserPrincipalName
"MSOL_LastPasswordChangeTimestamp"=$User.LastPasswordChangeTimestamp
"MSOL_BlockCredential"=$User.BlockCredential
"MSOL_LastDirSyncTime"=$User.LastDirSyncTime
"AD_User"="No AD Account"
"AD_User_Enabled"="No AD Account"
"AD_PasswordLastSet"="No AD Account"}
$Obj = New-Object -TypeName PSObject -Property $Properties
Write-Output $Obj | select MSOL_User,MSOL_LastPasswordChangeTimestamp,MSOL_BlockCredential,MSOL_LastDirSyncTime,AD_User,AD_User_Enabled,AD_PasswordLastSet
}
}