-
Notifications
You must be signed in to change notification settings - Fork 52
169 lines (148 loc) · 6.3 KB
/
windows-ci.yml
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
name: Windows test
on: [push]
jobs:
build:
name: Let's see what needs to be installed
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
Save-KbScanFile -Path C:\temp -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 -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: Clean defender so that KB2267602 installs
shell: powershell
run: |
Set-Location "$env:ProgramFiles\Windows Defender"
Start-Process -FilePath "$env:ProgramFiles\Windows Defender\MpCmdRun.exe" -ArgumentList "-removedefinitions -dynamicsignatures" -Wait -NoNewWindow -ErrorAction Ignore
Start-Process -FilePath "$env:ProgramFiles\Windows Defender\MpCmdRun.exe" -ArgumentList "-SignatureUpdate" -Wait -NoNewWindow -ErrorAction Ignore
- 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 -EnableException
if ($($saveit.Count) -gt 0) {
Get-KbInstalledSoftware -Pattern $needed.KBUpdate
}
} catch {
$error[0] | select *
if ("$PSItem" -notmatch "reboot") {
write-warning "$PSItem"
} else {
write-warning "Oh oops: $PSItem"
}
}
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
Save-KbScanFile -Path C:\temp -ErrorAction Stop
- name: Clean defender so that KB2267602 installs
shell: powershell
run: |
Set-Location "$env:ProgramFiles\Windows Defender"
Start-Process -FilePath "$env:ProgramFiles\Windows Defender\MpCmdRun.exe" -ArgumentList "-removedefinitions -dynamicsignatures" -Wait -NoNewWindow -ErrorAction Ignore
Start-Process -FilePath "$env:ProgramFiles\Windows Defender\MpCmdRun.exe" -ArgumentList "-SignatureUpdate" -Wait -NoNewWindow -ErrorAction Ignore
- 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 -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: |
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 -EnableException
if ($($saveit.Count) -gt 0) {
Get-KbInstalledSoftware -Pattern $needed.KBUpdate
}
} catch {
$error[0] | select *
throw $PSItem
}