I am trying to get the CreationTime
and Lastwritetime
using get-childitem
command and comparing it with the same assembly time to check if there is any difference for every 5 minutes.
Strangely there is a difference in milliseconds for every time when I fetch the records if the assembly did not change and it is causing the compare-object to fail.
Is there any way to fix this, other than converting the time to string format?
below is the command to fetch the details of the Assemblies
Get-ChildItem -Path 'C:\Windows\Microsoft.NET\assembly\GAC_MSIL' -include *.dll -Recurse|select @{Label=”AssemblyName”;Expression={$_.Name}},@{Label=”Size”; Expression={$_.Length}},@{label="Version";expression={if($_.versioninfo.productversion -eq $null) {
"NULL"
} else {
$_.versioninfo.productversion
}
}},@{Label=”CreationTime”; Expression={$_.CreationTime}},@{Label=”LastWriteTimeUtc”; Expression={$_.LastWriteTimeUtc}}
and running this command after 5 minutes and comparing with compare-object
compare-object -$oldobject $newObject -property Name,Lastwritetime