forked from jajp777/powershell-scripts-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Get-McAfeeDatDownload.ps1
24 lines (24 loc) · 1017 Bytes
/
Get-McAfeeDatDownload.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
#Get-McAfeeDatDownload
[CmdletBinding()]
[OutputType([System.IO.FileInfo])]
param (
$BaseUrl = 'http://download.nai.com/products/licensed/superdat/english/intel'
) #param
process {
$DatFile = ((Invoke-WebRequest -UseBasicParsing -Uri $BaseUrl).Links.href |
Where-Object { $_ -match '\.exe$' } |
Sort-Object -Descending)[0].Split('/')[-1]
$DatVersion = [int] $($DatFile.Split('x')[0])
$SourceDat = "$BaseUrl/$DatFile"
$LocalDat = "$env:ProgramFiles\$DatFile"
(New-Object System.Net.WebClient).DownloadFile("$SourceDat","$LocalDat")
while (-not (Test-Path -Path $LocalDat)) { Start-Sleep -Seconds 5 }
Start-Sleep -Seconds 3
Unblock-File -Path $LocalDat
$Hash = (Get-FileHash -Path $LocalDat -Algorithm SHA1).Hash
$RenamedDatFile = "$($DatFile.Split('.')[0])_$Hash`.exe"
$RenamedLocalDat = "$env:ProgramFiles\$RenamedDatFile"
Rename-Item -Path $LocalDat -NewName $RenamedLocalDat | Out-Null
Get-Item -Path $RenamedLocalDat
} #process
#Get-McAfeeDatDownload