Generate a .md5 file for every file in a folder

Tagged: 

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Miguel Oviedo Miguel Oviedo 4 months, 2 weeks ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #38786
    Profile photo of Miguel Oviedo
    Miguel Oviedo
    Participant

    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
    Profile photo of Stefan Werner
    Stefan Werner
    Participant

    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
    Profile photo of Miguel Oviedo
    Miguel Oviedo
    Participant

    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.
    Rgds.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.