-
Notifications
You must be signed in to change notification settings - Fork 2
/
Update-file.ps1
36 lines (25 loc) · 910 Bytes
/
Update-file.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<#
.SYNOPSIS
This will check for a file update and replace the original if a newer version exists. It will Optionally Restart a service too.
.DESCRIPTION
This will check for a file update and replace the original if a newer version exists. It will Optionally Restart a service too.
.PARAMETER LocalFile
Full path of the local file to check.
.PARAMETER RepositoryFile
Full path of the remote file to check.
.EXAMPLE
Update-file -localfile 'C:\folder\file.exe' -Repositoryfile '\\someshare\folder\file.exe' -servicename tomcat7
.NOTES
Daryl Bizsley 2015
#>
function Update-File{
param(
[string]$LocalFile,
[string]$RepositoryFile,
)
$localhash = (get-filehash $localFile).hash
$repositoryhash = (get-filehash $repositoryfile).hash
if ($localhash -ne $repositroyhash) {
copy-item $repositoryfile $localfile -force -confirm:$false
}
}