Link to home
Start Free TrialLog in
Avatar of SAM2009
SAM2009Flag for Canada

asked on

How to compare dates from csv with PowerShell?

Hi,


In PowerShell if in my csv file I have the date of lastlogondate in this format: 2019-01-29  10:34:10 AM

I need to get users with lastlogondate older than 90 days. My question is:

Should I compare like this:

1- Where-Object {([datetime]::($_.lastlogondate) -le (Get-Date).adddays(-90))

or Like this:

2 -Where-Object {([datetime]::FromFileTime($_.lastlogondate) -le (Get-Date).adddays(-90))
SOLUTION
Avatar of Adam Brown
Adam Brown
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SAM2009

ASKER

Many thanks to all!