forked from BornToBeRoot/NETworkManager
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreate-FileHash.ps1
More file actions
22 lines (17 loc) · 768 Bytes
/
Copy pathCreate-FileHash.ps1
File metadata and controls
22 lines (17 loc) · 768 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string]$Path
)
$Path = $Path.TrimEnd("\")
if(-not (Test-Path -Path $Path -PathType Container)) {
Write-Error "Path does not exist or is not a directory: $Path"
return
}
# Get current date as version
$now = Get-Date
$Version = "$($now.Year).$($now.Month).$($now.Day).0"
# Create SHA256 file hashes
foreach ($Hash in Get-ChildItem -Path $Path | Where-Object { $_.Name.StartsWith("NETworkManager_") -and ($_.Name.EndsWith(".zip") -or $_.Name.EndsWith(".msi")) } | Sort-Object -Descending | Get-FileHash) {
"$($Hash.Algorithm) | $($Hash.Hash) | $([System.IO.Path]::GetFileName($Hash.Path))" | Out-File -FilePath "$Path\NETworkManager_$($Version)_Checksums.sha256" -Encoding utf8 -Append
}