Hi,
The $password is an object of type ADUser. You'd use the property $password.passwordlastset
in the if condition and the comparison operator should be -eq
. Select-Object returns not the specified property but an object that has only the specified property.
$password = Get-ADUser -Identity test1 -Properties * | select passwordlastset
if ($password.passwordlastset -eq $null){
Write-Output "It's empty"
}
else {
Write-Output "It isn't empty"
}
Best Regards,
Ian
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.