Last active
March 2, 2016 10:38
-
-
Save absolutejam/c0d7cf9142080e5f6942 to your computer and use it in GitHub Desktop.
DCM - Keep file up to date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$FileToCopyPath = '\\MyFileSrv01\MyShare\MyFile.doc' | |
$FileToCheckPath = 'C:\Program Files\My Program\MyFile.doc' | |
If (!(Test-Path $FileToCheckPath)) { | |
Return 'False' | |
Break | |
} else { | |
$FileToCopyMD5 = New-Object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider | |
$FileToCopyHash = [System.BitConverter]::ToString($FileToCopyMD5.ComputeHash([System.IO.File]::ReadAllBytes($FileToCopyPath))) | |
$FileToCheckMD5 = New-Object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider | |
$FileToCheckHash = [System.BitConverter]::ToString($FileToCheckMD5.ComputeHash([System.IO.File]::ReadAllBytes($FileToCheckPath))) | |
if ($FileToCopyHash -eq $FileToCheckHash) { | |
Return 'True' | |
} else { | |
Return 'False' | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$FileToCopyPath = '\\MyFileSrv01\MyShare\MyFile.doc' | |
$FileToCheckPath = 'C:\Program Files\My Program\MyFile.doc' | |
Copy-Item -Path $FileToCopyPath -Destination $FileToCheckPath -Force |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment