Skip to content

Commit

Permalink
This should have been a PR
Browse files Browse the repository at this point in the history
  • Loading branch information
potatoqualitee committed Oct 12, 2022
1 parent 7e1f1e1 commit d36c652
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
16 changes: 13 additions & 3 deletions .github/workflows/windows-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,16 @@ jobs:
Write-Output "Importing kbupdate module"
Import-Module ./kbupdate.psd1 -ErrorAction Stop
Write-Output "Getting needed updates"
Get-KbNeededUpdate -ScanFilePath C:\temp\wsusscn2.cab -OutVariable needed -ErrorAction Stop -EnableException | Select-Object -First 1 -OutVariable saveit
Get-KbNeededUpdate -ScanFilePath C:\temp\wsusscn2.cab -ErrorAction Stop -EnableException -OutVariable saveit
$needed = $saveit
$null = mkdir C:\temp\xml
Write-Output "Found $($needed.Count) needed updates"
Write-Output "Will try to install $($saveit.Count) update"
$saveit | Export-CliXml -Path C:\temp\xml\results.xml
$saveit | Save-KbUpdate -Path C:\temp
$saveit.Title
$saveit.Link
$null = $saveit | Save-KbUpdate -Path C:\temp
- name: Clean defender so that KB2267602 installs
shell: powershell
Expand Down Expand Up @@ -134,14 +137,21 @@ jobs:
Write-Output "Importing kbupdate module"
Import-Module ./kbupdate.psd1 -ErrorAction Stop
Write-Output "Getting needed updates"
Get-KbNeededUpdate -ScanFilePath C:\temp\wsusscn2.cab -OutVariable needed -ErrorAction Stop -EnableException | Select-Object -First 1 -OutVariable saveit
Get-KbNeededUpdate -ScanFilePath C:\temp\wsusscn2.cab -ErrorAction Stop -EnableException -OutVariable saveit
$needed = $saveit
$null = mkdir C:\temp\xml
Write-Output "Found $($needed.Count) needed updates"
Write-Output "Will try to install $($saveit.Count) update"
$saveit | Export-CliXml -Path C:\temp\xml\results.xml
$saveit.Title
$saveit.Link
$null = $saveit | Save-KbUpdate -Path C:\temp
- name: Show all files in C:\temp
shell: powershell
run: Get-ChildItem C:\temp

- name: Installing updates
shell: powershell
run: |
Expand Down
13 changes: 9 additions & 4 deletions private/Start-DscUpdate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ function Start-DscUpdate {
}
}

if ($HotfixId) {
Write-PSFMessage -Level Verbose -Message "Hotfix detected, getting info"
if ($HotfixId -and -not $InputObject.Link) {
Write-PSFMessage -Level Verbose -Message "Hotfix detected without InputObject, getting info"
$InputObject += Get-KbUpdate -HotfixId $HotfixId -ComputerName $ComputerName
}

Expand Down Expand Up @@ -184,10 +184,14 @@ function Start-DscUpdate {
foreach ($object in $InputObject) {
if ($object.Link -and $RepositoryPath) {
try {
$filenames = Split-Path -Path $object.Link -Leaf
foreach ($filename in $filenames) {
foreach ($item in $object.Link) {
$filename = Split-Path -Path $item -Leaf
Write-PSFMessage -Level Verbose -Message "Adding $filename to $RepositoryPath"
$repofile = Join-Path -Path $RepositoryPath -ChildPath $filename
if (-not (Test-Path -Path $repofile)) {
Write-PSFMessage -Level Verbose -Message "File does not exist, trying to download $item to $repofile"
$null = Save-KbUpdate -Link $item -Path $RepositoryPath
}
if ($remotehome) {
$null = Copy-Item -Path $repofile -Destination "$remotehome\Downloads\$filename" -ToSession $remotesession -Recurse -Force -ErrorAction Stop
} else {
Expand Down Expand Up @@ -243,6 +247,7 @@ function Start-DscUpdate {

# try to automatically download it for them
if (-not $object -and $Pattern) {
Write-Message -Level Verbose -Message "No object and a pattern"
$object = Get-KbUpdate -ComputerName $ComputerName -Pattern $Pattern | Where-Object { $PSItem.Link -and $PSItem.Title -match $Pattern }
}

Expand Down

0 comments on commit d36c652

Please sign in to comment.