Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This script needs exactly 1 argument to search for any MHL files
- # thus, only works for a project that export MHL files
- # If we want to use it in any other projects, then we have to write different script
- param($arg1)
- if (!$arg1) {
- Write-Host "You have to give me a directory name to search for the MHL files"
- return
- }
- Write-Host "Searching for MHL files in:" $arg1
- $mhl_list = Get-ChildItem -Path $arg1\*.mhl -Recurse -File
- $currentDirectory = $PWD
- foreach ($mhl_file in $mhl_list) {
- # We will walk into each MHL files found in the directory
- Write-Host "Verifying:" $mhl_file
- [xml]$xmlObj = Get-Content -Path $mhl_file
- if (!$xmlObj) {
- write-host "unexpected Null XML Object:" $mhl_file
- continue
- }
- # We'll have to step into this MHL file folder, in order to get the files correctly
- write-host "Got MHL:" $mhl_file " from directory:" $mhl_file.directory
- cd $mhl_file.directory
- # Now we will walk into each items refer to by this MHL
- foreach ($entry in $xmlObj.hashlist.hash) {
- # skip the creator, etc
- $md5 = Get-FileHash -Path $entry.File -Algorithm MD5
- if ($md5.Hash -ne $entry.md5) {
- # Complain, loudly...
- write-host "HASH FAILED:" $md5.Path " expecting:" $entry.md5 " got:" $md5.Hash
- }
- else {
- write-host $entry.File $md5.Hash "OK"
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement