-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGlobals.ps1
More file actions
46 lines (38 loc) · 3.54 KB
/
Globals.ps1
File metadata and controls
46 lines (38 loc) · 3.54 KB
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
45
46
$invocationPath = Split-Path -Path $MyInvocation.MyCommand.Path -Parent
# CHANGE ME
$wsusRoot = "C:\ProgramData\chocolatey\lib\wsus-offline-update\tools\wsusoffline"
$destinationPath = "Z:\sources\Microsoft\Windows"
# CHANGE ME
. (Join-Path $invocationPath "Functions.ps1")
$sourceWimsPath = (Join-Path $invocationPath "SourceWims")
$scriptPath = (Join-Path $invocationPath "Scripts")
$driversPath = (Join-Path $invocationPath "Drivers")
$wsusUpdates = (Join-Path $wsusRoot "client\w{0}-x64\glb")
function GetWimArguments([string]$windowsVersion)
{
$args = @()
$args += '-wimFile "' + (Join-Path (Join-Path $sourceWimsPath $windowsVersion) "install.wim") + '"'
$args += '-destination "' + (Join-Path $destinationPath $windowsVersion) + '"'
$args += '-updatesPath "' + [string]::Format($wsusUpdates, $windowsVersion.Replace('.', '')) + '"'
$args += '-driversPath "' + (Join-Path $driversPath $windowsVersion) + '"'
return (" " + [String]::Join(" ", $args))
}
function GetBootWimArguments()
{
$windowsVersion = "boot"
$args = @()
$args += '-wimFile "' + (Join-Path (Join-Path $sourceWimsPath $windowsVersion) "boot.wim") + '"'
$args += '-destination "' + (Join-Path $destinationPath $windowsVersion) + '"'
$args += '-driversPath "' + (Join-Path $driversPath $windowsVersion) + '"'
$args += '-isBoot 1'
return (" " + [String]::Join(" ", $args))
}
function CheckUpdates([string]$windowsVersion)
{
$process = Start-Process -FilePath (Join-Path $wsusRoot "cmd\DownloadUpdates.cmd") -ArgumentList @([string]::Format("w{0}-x64 glb", $windowsVersion.Replace('.', '')), "/verify") -Wait -PassThru;
$exitCode = $process.ExitCode
if ($exitCode -ne 0)
{
throw "Error downloading updates for Windows ${windowsVersion}, exit code was ${exitCode}"
}
}