So I was reading up on the AD Module filters. I found a thing, Microsoft usually says keep it simple. I found an over complex way of initializing a date variable. So what did the documentation suggest:
$date_net = new-object System.DateTime -ArgumentList @(2007,1,1,0,0,0)
Whoa.. Yes you can use .NET but if possible use Powershell cmdlets.
Do we have any cmdlet we can use?
Get-Date can be initialized with year, month and day.
$date_ps = Get-Date -Year 2007 -Month 1 -Date 1
That looks easier to read so it is better.
But are they the same.
And they aren’t.
So what is the difference?
Let’s convert it to the
PS C:\> $date_ps -eq $date_net False PS C:\> $date_ps.ToFileTime() 128120796000000001 PS C:\> $date_net.ToFileTime() 128120796000000000
Here we see that we get a 100-nanosecond difference.
I’m not really sure why.
But now we know that if you want the real 12am you can’t use
As it will add a 100ns extra.
Bonus link to MSDN article for DateTime Structure.