So here's what's up. I'm in the process of troubleshooting some code, and I'm noticing an odd behavior. If I use the following code:
$UpdateHistory = Get-WUHistory -last 1
$TodaysDate = (Get-Date)
$UpdateHistory.Date
$TodaysDate.DateTime
I get the output:
Sunday, April 17, 2022 10:01:13 AM
Thursday, April 21, 2022 11:23:00 AM
However, if I use this code:
$UpdateHistory = Get-WUHistory -last 1
$TodaysDate = (Get-Date)
$UpdateHistory
$UpdateHistory.Date
$TodaysDate.DateTime
I get this output:
ComputerName Operationname Result Date Title
------------ ------------- ------ ---- -----
RedactedComputerName Installation Succeeded 4/17/2022 3:01:1... Windows Malicious Software Removal Tool x64 - v5.100 (KB890830)
Date : 4/17/2022 12:00:00 AM
Day : 17
DayOfWeek : Sunday
DayOfYear : 107
Hour : 10
Kind : Unspecified
Millisecond : 0
Minute : 1
Month : 4
Second : 13
Ticks : 637857864730000000
TimeOfDay : 10:01:13
Year : 2022
DateTime : Sunday, April 17, 2022 10:01:13 AM
Thursday, April 21, 2022 11:23:56 AM
What the heck is going on? The reason for the $Updatehistory on line 4 was simply to see a list of the entries, but it appears to be fundamentally changing the object. It's throwing me for a loop.