I am trying to get a checksum of a remote file using Win32_FileSpecification class via WMI, but am running into a few problems.
- It uses CheckID as the key, which looks to be similar to the path with '\'s changed to '.'s and a GUID at the end. How do you get from a path (C:\test.txt) to this CheckID format (preferably from CIM_DataFile)? What is the significance of the GUID?
- Regardless of the above, when
gwmi WIN32_FileSpecification
is run, all files have an empty MD5Checksum value in the output. Should MD5Checksum be populated by Windows when getting an instance, and if not is there a method to invoke to populate it? It appears the only method on WIN32_FileSpecification is Invoke which is not implemented.
My only solution has been to write a cmdlet for PowerShell using remoting to run a script and generate the checksum value. This works but isn't the cleanest as there is no direct way to calculate an MD5 in PowerShell so there is additional maintenance of the code.
Thanks!