-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget-prefetch.ps1
44 lines (33 loc) · 996 Bytes
/
get-prefetch.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
37
38
39
40
41
42
43
44
param (
[Parameter(ParameterSetName='Local', mandatory=$true)]
[ValidateScript({(Test-Path $_) -and -not (get-item $_).PSIsContainer})]
[string] $Path,
[Parameter(ParameterSetName='Network', mandatory=$true)]
[uri] $URL,
[Parameter(ParameterSetName='Local', mandatory=$true)]
[Parameter(ParameterSetName='Network', mandatory=$true)]
[string] $Name
)
switch ($PsCmdlet.ParameterSetName)
{
"Local" {
Write-Host $d;
$URL = "http://REPLACEME"
break
}
"Network" {
$Path = [System.IO.Path]::GetTempFileName()
invoke-webrequest $URL -outfile $Path
$File = get-item $Path
}
}
$File = get-item $Path
#Calculate Hash and File Size
$SHA1 = (Get-FileHash $File -Algorithm SHA1).hash
$SHA256 = (Get-FileHash $File -Algorithm SHA256).hash
$Size = $File.length
#Combine
$Prefetch = "prefetch $Name sha1:$SHA1 size:$Size $URL sha256:$SHA256"
#Output
write-output $Prefetch
$prefetch | Clip