Skip to content

Commit

Permalink
Enable local installs when WinRM is Disabled (#194)
Browse files Browse the repository at this point in the history
* works

* updates

* Update pester.ps1

* ugh

* Update pester.ps1

* Update pester.ps1

* made that mof a mof

* Update pester.ps1

* undo

* do not enable winrm

* Update pester.ps1

* fix

* upd

* fix install of KB2267602

* Update windows-ci.yml

* Update windows-ci.yml

* Update windows-ci.yml

* Update windows-ci.yml

* remove line

* Update windows-ci.yml
  • Loading branch information
potatoqualitee authored Oct 6, 2022
1 parent 48b2f46 commit 5937c35
Show file tree
Hide file tree
Showing 3 changed files with 247 additions and 46 deletions.
95 changes: 86 additions & 9 deletions .github/workflows/windows-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,99 @@ jobs:
modules-to-cache: PSFramework, PSSQLite
shell: powershell, pwsh

- name: Starting services and enabling WinRM
- name: Starting services and disabling WinRM
shell: powershell
run: |
Write-Output "Starting services"
Set-Service wuauserv -StartupType Automatic
Set-Service WinRM -StartupType Automatic
Start-Service wuauserv
Write-Output "Enabling WinRM"
winrm quickconfig -quiet
Write-Output "Disabling WinRM"
Set-Service WinRM -StartupType Disabled
Get-Service WinRM | Stop-Service -ErrorAction Continue
#Disable-PSRemoting -Force -ErrorAction Ignore
#winrm delete winrm/config/Listener?Address=*+Transport=HTTP
#winrm quickconfig -quiet
- name: Run Test-WSMan
shell: powershell
run: |
Test-WSMan -ErrorAction Continue
- name: Downloading kbupdate-library and scanfile
shell: powershell
run: |
Write-Output "Downloading freshest library"
Install-Module kbupdate-library -Confirm:$false -Force
Import-Module ./kbupdate.psd1 -ErrorAction Stop
- name: Getting needed updates
shell: powershell
run: |
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
$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
$null = $saveit | Save-KbUpdate -Path C:\temp
- name: Installing updates
shell: powershell
run: |
Import-Module ./kbupdate.psd1 -ErrorAction Stop
$saveit = Import-CliXml -Path C:\temp\xml\results.xml
Write-Output "Installing needed updates"
try {
$saveit | Install-KbUpdate -RepositoryPath C:\temp -Verbose -ErrorAction Stop -EnableException
if ($($saveit.Count) -gt 0) {
Get-KbInstalledSoftware -Pattern $needed.KBUpdate
}
} catch {
$error[0] | select *
throw $PSItem
}
Write-Output "Saving scanfile"
Save-KbScanFile -Path C:\temp -AllowClobber
second:
name: Let's try another VM
runs-on: windows-latest

steps:
- uses: actions/checkout@v1
- name: Install and cache PowerShell modules
uses: potatoqualitee/[email protected]
with:
modules-to-cache: PSFramework, PSSQLite
shell: powershell, pwsh

- name: Starting services and disabling WinRM
shell: powershell
run: |
Write-Output "Starting services"
Set-Service wuauserv -StartupType Automatic
Start-Service wuauserv
Write-Output "Disabling WinRM"
Set-Service WinRM -StartupType Disabled
Get-Service WinRM | Stop-Service -ErrorAction Continue
#Disable-PSRemoting -Force -ErrorAction Ignore
#winrm delete winrm/config/Listener?Address=*+Transport=HTTP
#winrm quickconfig -quiet
- name: Run Test-WSMan
shell: powershell
run: |
Test-WSMan -ErrorAction Continue
- name: Downloading kbupdate-library and scanfile
shell: powershell
run: |
Write-Output "Downloading freshest library"
Install-Module kbupdate-library -Confirm:$false -Force
Import-Module ./kbupdate.psd1 -ErrorAction Stop
- name: Getting needed updates
shell: powershell
run: |
Expand All @@ -55,7 +127,12 @@ jobs:
Import-Module ./kbupdate.psd1 -ErrorAction Stop
$saveit = Import-CliXml -Path C:\temp\xml\results.xml
Write-Output "Installing needed updates"
$saveit | Install-KbUpdate -RepositoryPath C:\temp -Verbose
if ($($saveit.Count) -gt 0) {
Get-KbInstalledSoftware -Pattern $needed.KBUpdate
try {
$saveit | Install-KbUpdate -RepositoryPath C:\temp -Verbose -ErrorAction Stop -EnableException
if ($($saveit.Count) -gt 0) {
Get-KbInstalledSoftware -Pattern $needed.KBUpdate
}
} catch {
$error[0] | select *
throw $PSItem
}
Loading

0 comments on commit 5937c35

Please sign in to comment.