Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit cb50211

Browse files
committed
Update
1 parent 63d11b0 commit cb50211

File tree

2 files changed

+47
-14
lines changed

2 files changed

+47
-14
lines changed

‎WindowsImageAutoUpdater/AutoUpdater.ps1‎

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,35 @@ function logger{
77
$ScriptLocation = Get-Location
88
$ScriptLocation = $ScriptLocation.Path
99

10+
if (!Test-Path $ScriptLocation\Images.json) {
11+
logger -TextToLog "$(Get-Date) ERROR: Cannot find Images.json in current folder ($ScriptLocation)\n"
12+
exit
13+
}
14+
15+
if (!Test-Path $ScriptLocation\DefaultUnattend.xml) {
16+
logger -TextToLog "$(Get-Date) ERROR: Cannot find DefaultUnattend.xml in current folder ($ScriptLocation)\n"
17+
exit
18+
}
19+
20+
if (!Test-Path $ScriptLocation\SpecGatherScript.vbs) {
21+
logger -TextToLog "$(Get-Date) ERROR: Cannot find SpecGatherScript.vbs in current folder ($ScriptLocation)\n"
22+
exit
23+
}
24+
25+
$ConfigObject = Get-Content -Path $ScriptLocation\Images.json | ConvertFrom-Json
26+
27+
if ($ConfigObject -eq $null) {
28+
logger -TextToLog "$(Get-Date) ERROR: Unable to import config from file\n"
29+
exit
30+
}
31+
32+
$DefaultUnattend = Get-Content -Path $ScriptLocation\DefaultUnattend.xml
33+
34+
if ($DefaultUnattend -eq $null) {
35+
logger -TextToLog "$(Get-Date) ERROR: Unable to import DefaultUnattend from file\n"
36+
exit
37+
}
38+
1039
if (Test-Path $ScriptLocation\ImageUpdater1.log) {
1140
logger -TextToLog "$(Get-Date) INFO: Removing ImageUpdater1.log\n"
1241
Remove-Item $ScriptLocation\ImageUpdater1.log
@@ -15,6 +44,18 @@ if (Test-Path $ScriptLocation\ImageUpdater.log) {
1544
logger -TextToLog "$(Get-Date) INFO: Moving ImageUpdater.log to ImageUpdater1.log\n"
1645
Move-Item $ScriptLocation\ImageUpdater.log $ScriptLocation\ImageUpdater1.log
1746
}
47+
48+
# Make sure temp path exists
49+
if( (Test-Path -Path $ConfigObject.ScratchFolder ) -eq $false ) {
50+
logger -TextToLog "$(Get-Date) INFO: Temp Folder $($ConfigObject.ScratchFolder) doesn't exist, creating it."
51+
$createPath = New-Item -Path $ConfigObject.ScratchFolder -ItemType directory
52+
53+
if( $createPath -eq $false ) {
54+
logger -TextToLog "$(Get-Date) ERROR: Failed to create scratch path $($ConfigObject.ScratchFolder). Exiting."
55+
exit
56+
}
57+
}
58+
1859
# Below came from https://github.com/breich/UpdateWdsFromWsus
1960
function Update-WdsFromWsus() {
2061

@@ -24,23 +65,16 @@ function Update-WdsFromWsus() {
2465
)
2566

2667

27-
# Make sure temp path exists
28-
if( (Test-Path -Path $ScratchFolder ) -eq $false ) {
29-
logger -TextToLog "$(Get-Date) INFO: Temp Folder $ScratchFolder doesn't exist, creating it."
30-
$createPath = New-Item -Path $ScratchFolder -ItemType directory
3168

32-
if( $createPath -eq $false ) {
33-
34-
logger -TextToLog "$(Get-Date) ERROR: Failed to create scratch path $ScratchFolder. Returning from the fuction."
35-
return $false
36-
}
37-
}
3869

3970
logger -TextToLog "$(Get-Date) INFO: Getting list of install images from WDS"
4071
$Images = Get-WdsInstallImage
4172

4273
# Update each image.
4374
foreach( $Image in $Images ) {
75+
if ($Image.ImageName.Contains(" | OLD VERSION")) {
76+
continue
77+
}
4478
Update-WdsImage -Image $Image -Scratch $ScratchFolder -WsusContent $WsusContent
4579
}
4680
}
@@ -123,10 +157,9 @@ function Update-WdsImage() {
123157
# If Import-WdsInstallImage is called with an empty or null UnattendFile, import fails.
124158
if( $Image.UnattendFile -eq $null -or $Image.UnattendFile -eq "" ) {
125159
logger -TextToLog "$(Get-Date) INFO: Import-WdsInstallImage -ImageGroup $Image.ImageGroup -Path $ExportDestination -ImageName -DisplayOrder 0 -NewImageName $ImageName"
126-
$import = Import-WdsInstallImage -ImageGroup $Image.ImageGroup -Path $ExportDestination -DisplayOrder 0 -NewImageName $ImageName
160+
$import = Import-WdsInstallImage -ImageGroup $Image.ImageGroup -Path $ExportDestination -DisplayOrder 0 -NewImageName $ImageName-Multicast -TransmissionName $ImageName+" MultiCast"
127161
} else {
128-
$import = Import-WdsInstallImage -ImageGroup $Image.ImageGroup -UnattendFile $Image.UnattendFile -Path $ExportDestination -ImageName $OldImageName -DisplayOrder 0 -NewImageName $ImageName
129-
162+
$import = Import-WdsInstallImage -ImageGroup $Image.ImageGroup -UnattendFile $Image.UnattendFile -Path $ExportDestination -ImageName $OldImageName -DisplayOrder 0 -NewImageName $ImageName -Multicast -TransmissionName $ImageName+" MultiCast"
130163
}
131164

132165
if( $import -eq $null ) {

‎WindowsImageAutoUpdater/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
}
2727
],
2828
"ReportingURL": "",
29-
"ScratchDir": "",
29+
"ScratchFolder": "",
3030
"WsusContentFolderPath": ""
3131
}
3232
```

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /