@@ -221,13 +221,6 @@ function Set-PrerequisiteOptions {
221
221
sc.exe config wuauserv start= disabled
222
222
sc.exe stop wuauserv
223
223
224
- # Windows Defender periodically consumes 100% of the CPU.
225
- # TODO(pjh): this (all of a sudden, ugh) started failing with "The term
226
- # 'Set-MpPreference' is not recognized...". Investigate and fix or remove.
227
- # Log-Output "Disabling Windows Defender service"
228
- # Set-MpPreference -DisableRealtimeMonitoring $true
229
- # Uninstall-WindowsFeature -Name 'Windows-Defender'
230
-
231
224
# Use TLS 1.2: needed for Invoke-WebRequest downloads from github.com.
232
225
[Net.ServicePointManager ]::SecurityProtocol = `
233
226
[Net.SecurityProtocolType ]::Tls12
@@ -237,6 +230,24 @@ function Set-PrerequisiteOptions {
237
230
Install-Module - Name powershell- yaml - Force
238
231
}
239
232
233
+ # Disables Windows Defender realtime scanning if this Windows node is part of a
234
+ # test cluster.
235
+ #
236
+ # ${kube_env} must have already been set.
237
+ function Disable-WindowsDefender {
238
+ # Windows Defender periodically consumes 100% of the CPU, so disable realtime
239
+ # scanning. Uninstalling the Windows Feature will prevent the service from
240
+ # starting after a reboot.
241
+ # TODO(pjh): move this step to image preparation, since we don't want to do a
242
+ # full reboot here.
243
+ if ((Test-IsTestCluster ${kube_env} ) -and
244
+ ((Get-WindowsFeature - Name ' Windows-Defender' ).Installed)) {
245
+ Log- Output " Disabling Windows Defender service"
246
+ Set-MpPreference - DisableRealtimeMonitoring $true
247
+ Uninstall-WindowsFeature - Name ' Windows-Defender'
248
+ }
249
+ }
250
+
240
251
# Creates directories where other functions in this module will read and write
241
252
# data.
242
253
function Create-Directories {
0 commit comments