I am looking to write a single string to a UI displaying the last time a Windows Update was applied using powershell.
I am currently using the command
$LastInstallDate = (Get-HotFix | Sort-Object -Property InstalledOn)[-1] | Select-Object -ExpandProperty 'InstalledOn'
However this returns errors on random machines I try it on
Exception getting "InstalledOn": "Exception calling "Parse" with "2" argument(s): "String was not recognized as a valid DateTime.""
When this does work occasionally, it also shows the time at 00:00:00, I would like to axe this off the output if possible so I just get the date.
TIA