Generate a .md5 file for every file in a folder

This topic contains 2 replies, has 2 voices, and was last updated by  Miguel Oviedo 2 years, 2 months ago.

  • Author
  • #38786

    Miguel Oviedo

    Hello, I am a newbie using powershell, I am using Get-filehash cmdlet in order to obtain the hash of all .pst files of a directory and I would like to generate a .md5 file for every file/hash, any idea of how to do this?

  • #38789

    Stefan Werner

    Something like this?

    $files = Get-childitem -Path C:\Temp -Include "*.pst"
    Foreach ($file in $files)
        $hash = (Get-FileHash -Path $file.fullname -Algorithm MD5).hash
        Add-Content -Path ($file.fullname + '.md5') -Value $hash
  • #38792

    Miguel Oviedo

    Exactly like that, thank your solution Stefan. I am trying to put together a script that take all exchange users inactive older than 6 months and for each one:

    – Export mailbox to .pst file
    After validate that export complete sucessfully
    – Calculate a hash to that .pst file
    – Remove the mailbox from exchange
    – Remove the user from Active Directory

    So I am trying to put the pieces together in one script, so I may comeback to ask for some help in the future.

You must be logged in to reply to this topic.