Hi, the below script runs properly, I am able to return results of the SamAccountName as well as password expiration date. However, I get this error, and scratching my head on how to resolve.
get-date : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.
At C:\Users\a_dtuan\Scripts\testpwdexpiration.ps1:7 char:19
-
($_.ExpiryDate | get-date) -gt (get-date) -and ($_.ExpiryDate | g ...
-
~~~~~~~~
- CategoryInfo : InvalidArgument: ( [Get-Date], ParameterBindingException
Get-ADUser -filter * -SearchBase "OU=Users,DC=XX,DC=XX,DC=XX" -properties SamAccountName,PasswordNeverExpires,msDS-UserPasswordExpiryTimeComputed |
where {
$.enabled -eq $true -and $.PasswordNeverExpires -eq $False
} |
select @{Name=“ID”;Expression={$.sAMAccountName}},@{Name=“ExpiryDate”;Expression={([datetime]::FromFileTime($.“msDS-UserPasswordExpiryTimeComputed”)).DateTime}} |
where {
($.ExpiryDate | get-date) -gt (get-date) -and ($_.ExpiryDate | get-date) -lt (get-date).adddays(7)} |
Export-Csv C:\temp\PwdExpiration\pwdexpiration.csv -notypeinformation