-
-
Notifications
You must be signed in to change notification settings - Fork 54
/
W10ANDW11-NETWORK-TCP-DESUBOPTIMIZATION.ps1
885 lines (839 loc) · 41.2 KB
/
W10ANDW11-NETWORK-TCP-DESUBOPTIMIZATION.ps1
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
<#
.SYNOPSIS
This Script desuboptimize a lot W10 & W11 TCP Settings.
.NOTES
Version: 2.02
Author: MysticFoxDE (Alexander Fuchs)
Creation Date: 23.04.2023
.LINK
https://www.golem.de/news/tcp-die-versteckte-netzwerkbremse-in-windows-10-und-11-2302-172043.html
https://www.borncity.com/blog/2023/01/30/microsofts-tcp-murks-in-windows-10-und-11-optimierung-ist-mglich
https://www.borncity.com/blog/2023/02/14/windows-10-11-grottige-netzwerktransfer-leistung-hohe-windows-11-cpu-last-teil-1
https://www.borncity.com/blog/2023/02/14/windows-11-netzwerktransfer-leistung-und-cpu-last-optimieren-teil-2
https://administrator.de/tutorial/wie-man-das-windows-10-und-11-tcp-handling-wieder-desuboptimieren-kann-5529700198.html#comment-5584260697
https://community.spiceworks.com/topic/post/10299845
#>
# PROMPT THE USER TO ELEVATE THE SCRIPT
# Great thanks to "Karl Wester-Ebbinghaus/Karl-WE" for this very useful aid.
if (-not (New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))
{
$arguments = "-NoExit -ExecutionPolicy Bypass -File `"$($myInvocation.MyCommand.Definition)`""
Start-Process powershell -Verb runAs -ArgumentList $arguments
exit
}
# DETAILED SCRIPTDEBUGING ON=Enabled OFF=Disabled
$DEDAILEDDEBUG = "OFF"
#BASIC VARIABLES
$FULLYCOMPLETED = $true
# CREATE A BACKUP OF THE EXISTING SETTINGS
$BAKLOGPATH = "C:\BACKUP"
$BAKLOGFILENAME = "WINDOWS10AND11-NETWORK-DESUBOPTIMIZATION.log"
$BAKLOGDATE = Get-Date
$TIMESTAMP = Get-Date -Format o | ForEach-Object { $_ -replace ":", "." }
if (!(Test-Path $BAKLOGPATH))
{New-Item -Path $BAKLOGPATH -ItemType Directory}
Start-Transcript -Path "$BAKLOGPATH\$BAKLOGFILENAME" -Append
Write-Host (" ") -ForegroundColor White
Write-Host ("************************************************************************************************************") -ForegroundColor White
Write-Host ("*** Beginning of the configuration-backup from " + $BAKLOGDATE) -ForegroundColor White
Write-Host ("************************************************************************************************************") -ForegroundColor White
Write-Host (" ") -ForegroundColor White
Write-Host ("Get-NetOffloadGlobalSetting: ") -ForegroundColor White
Get-NetOffloadGlobalSetting
Write-Host ("------------------------------------------------------------------------------------------------------------") -ForegroundColor White
Write-Host ("netsh int tcp show global: ") -ForegroundColor White
netsh int tcp show global
Write-Host ("------------------------------------------------------------------------------------------------------------") -ForegroundColor White
Write-Host ("netsh int tcp show supplemental:") -ForegroundColor White
netsh int tcp show supplemental
Write-Host ("------------------------------------------------------------------------------------------------------------") -ForegroundColor White
Write-Host ("Get-NetAdapterAdvancedProperty:") -ForegroundColor White
Get-NetAdapterAdvancedProperty | FT -AutoSize
Write-Host ("------------------------------------------------------------------------------------------------------------") -ForegroundColor White
Write-Host ("Get-NetAdapterRsc:") -ForegroundColor White
Get-NetAdapterRsc | FT -AutoSize
Write-Host ("------------------------------------------------------------------------------------------------------------") -ForegroundColor White
Write-Host ("Get-NetAdapterRss:") -ForegroundColor White
Get-NetAdapterRss | FL
Write-Host ("------------------------------------------------------------------------------------------------------------") -ForegroundColor White
Write-Host ("Status ACK-Frequency: (Registry)") -ForegroundColor White
$NICs = Get-NetAdapter -Physical | Select-Object DeviceID, Name
foreach ($adapter in $NICs)
{
$NICGUID = $adapter | Select-Object DeviceID | Select DeviceID -ExpandProperty DeviceID | Out-String -Stream
$NICNAME = $adapter | Select-Object Name | Select Name -ExpandProperty Name | Out-String -Stream
$REGKEYPATH = "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\$NICGUID\" | Out-String -Stream
$TARGETVALUE = 1
$CHECKVALUE = Get-ItemProperty -Path "$REGKEYPATH" -Name "TcpAckFrequency" -ErrorAction SilentlyContinue | Select-Object -ExpandProperty "TcpAckFrequency"
if (($CHECKVALUE -ne $null) -and ($CHECKVALUE.Length -gt 0))
{
Write-Host ("The TcpAckFrequency Key for NIC " + $NICNAME + " is present in the registry with value " + $CHECKVALUE + ".") -ForegroundColor White
}
else
{
Write-Host ("The TcpAckFrequency Key for NIC " + $NICNAME + " is NOT present in the registry.") -ForegroundColor White
}
}
Write-Host ("------------------------------------------------------------------------------------------------------------") -ForegroundColor White
Write-Host ("Status TCP-Delay: (Registry)") -ForegroundColor White
$NICs = Get-NetAdapter -Physical | Select-Object DeviceID, Name
foreach ($adapter in $NICs)
{
$NICGUID = $adapter | Select-Object DeviceID | Select DeviceID -ExpandProperty DeviceID | Out-String -Stream
$NICNAME = $adapter | Select-Object Name | Select Name -ExpandProperty Name | Out-String -Stream
$REGKEYPATH = "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\$NICGUID\" | Out-String -Stream
$TARGETVALUE = 1
$CHECKVALUE = Get-ItemProperty -Path "$REGKEYPATH" -Name "TcpNoDelay" -ErrorAction SilentlyContinue | Select-Object -ExpandProperty "TcpNoDelay"
if (($CHECKVALUE -ne $null) -and ($CHECKVALUE.Length -gt 0))
{
Write-Host ("The TcpNoDelay Key for NIC " + $NICNAME + " is present in the registry with value " + $CHECKVALUE + ".") -ForegroundColor White
}
else
{
Write-Host ("The TcpNoDelay Key for NIC " + $NICNAME + " is NOT present in the registry.") -ForegroundColor White
}
}
Write-Host ("------------------------------------------------------------------------------------------------------------") -ForegroundColor White
Write-Host ("Create Backup from HKLM\SYSTEM\CurrentControlSet\Services\Winsock to " + $BAKLOGPATH + "\WinSock-RegBackup-" + $TIMESTAMP + ".reg") -ForegroundColor White
reg export HKLM\SYSTEM\CurrentControlSet\Services\Winsock $BAKLOGPATH\WinSock-RegBackup-$TIMESTAMP.reg
Write-Host ("------------------------------------------------------------------------------------------------------------") -ForegroundColor White
Write-Host ("Create Backup from HKLM\SYSTEM\CurrentControlSet\Services\WinSock2 to " + $BAKLOGPATH + "\Winsock2-RegBackup-" + $TIMESTAMP + ".reg") -ForegroundColor White
reg export HKLM\SYSTEM\CurrentControlSet\Services\WinSock2 $BAKLOGPATH\WinSock2-RegBackup-$TIMESTAMP.reg
Write-Host ("------------------------------------------------------------------------------------------------------------") -ForegroundColor White
Write-Host ("Create Backup from HKLM\SYSTEM\CurrentControlSet\Control\Nsi to " + $BAKLOGPATH + "\NSI-RegBackup-" + $TIMESTAMP + ".reg") -ForegroundColor White
reg export HKLM\SYSTEM\CurrentControlSet\Control\Nsi $BAKLOGPATH\NSI-RegBackup-$TIMESTAMP.reg
Write-Host ("------------------------------------------------------------------------------------------------------------") -ForegroundColor White
Write-Host ("Create Backup from HKLM\SYSTEM\CurrentControlSet\Services\Tcpip to " + $BAKLOGPATH + "\TCPIP-RegBackup-" + $TIMESTAMP + ".reg") -ForegroundColor White
reg export HKLM\SYSTEM\CurrentControlSet\Services\Tcpip $BAKLOGPATH\TCPIP-RegBackup-$TIMESTAMP.reg
Write-Host ("------------------------------------------------------------------------------------------------------------") -ForegroundColor White
Write-Host ("Create Backup from HKLM\SYSTEM\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318} to " + $BAKLOGPATH + "\NICSETTINGS-RegBackup-" + $TIMESTAMP + ".reg") -ForegroundColor White
reg export "HKLM\SYSTEM\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}" $BAKLOGPATH\NICSETTINGS-RegBackup-$TIMESTAMP.reg
Write-Host (" ") -ForegroundColor White
Write-Host ("************************************************************************************************************") -ForegroundColor White
Write-Host ("*** End of the configuration-backup from " + $BAKLOGDATE) -ForegroundColor White
Write-Host ("************************************************************************************************************") -ForegroundColor White
Write-Host (" ") -ForegroundColor White
Write-Host ("************************************************************************************************************") -ForegroundColor White
Write-Host ("*** Beginning of change logging from " + $BAKLOGDATE) -ForegroundColor White
Write-Host ("************************************************************************************************************") -ForegroundColor White
Write-Host (" ") -ForegroundColor White
# CHECK HYPER-V STATUS
Write-Host "Check Hyper-V status" -ForegroundColor Cyan
$HYPERVSTATE = Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V | Select-Object State | Select State -ExpandProperty State | Out-String -Stream
if($HYPERVSTATE -eq "Enabled")
{
Write-Host " Hyper-V is enabled." -ForegroundColor Yellow
}
else
{
Write-Host " Hyper-V is disabled." -ForegroundColor Green
}
Write-Host " "
# RESET TCP STACK
Write-Host "Reset the TCP-Stack settings" -ForegroundColor Cyan
netsh interface tcp reset
# RESET WINSOCK
Write-Host "Reset the WINSOCK settings" -ForegroundColor Cyan
netsh winsock reset
# DISABLE PACKET COALESCING FILTER ON WINDOWS TCP-STACK
if ($HYPERVSTATE -eq "Disabled")
{
$DISABLEPCFOK = $true
Write-Host "Start disabling PACKET COALESCING FILTER on Windows TCP-Stack" -ForegroundColor Cyan
Write-Host " Check current state of PACKET COALESCING FILTER" -ForegroundColor Gray
$STATUSPCF = Get-NetOffloadGlobalSetting | Select-Object PacketCoalescingFilter | Select PacketCoalescingFilter -ExpandProperty PacketCoalescingFilter | Out-String -Stream
if ($STATUSPCF -eq "Disabled")
{
Write-Host " The PACKET COALESCING FILTER is already disabled, so nothing to do. :-)" -ForegroundColor Green
}
else
{
Write-Host " The PACKET COALESCING FILTER is enabled, try next to disable it." -ForegroundColor Yellow
try
{
Set-NetOffloadGlobalSetting -PacketCoalescingFilter Disabled -ErrorAction Stop
Write-Host " The PACKET COALESCING FILTER is successfully set to disabled. :-)" -ForegroundColor Green
}
catch
{
$DISABLEPCFOK = $false
Write-Host (" The PACKET COALESCING FILTER could not set to disabled. :-(") -ForegroundColor Red
if ($DEDAILEDDEBUG -eq "ON")
{Write-Host $_ -ForegroundColor Red}
}
}
if ($DISABLEPCFOK -eq $true)
{
Write-Host "Disabling PACKET COALESCING FILTER has been finished successfully. :-)" -ForegroundColor Cyan
}
else
{
$FULLYCOMPLETED = $false
Write-Host "Disabling PACKET COALESCING FILTER can't finished successfully. :-(" -ForegroundColor Red
}
}
else
{
Write-Host "Due to the installed Hyper-V role, the optimization of the PACKET COALESCING FILTER ON WINDOWS TCP-STACK is skipped." -ForegroundColor Yellow
}
# DISABLE RECEIVE SIDE SCALING ON WINDOWS TCP-STACK
if ($HYPERVSTATE -eq "Disabled")
{
$DISABLERSSOK = $true
Write-Host "Start disabling RECEIVE SIDE SCALING on Windows TCP-Stack" -ForegroundColor Cyan
Write-Host " Check current state of RECEIVE SIDE SCALING" -ForegroundColor Gray
$STATUSRSS = Get-NetOffloadGlobalSetting | Select-Object ReceiveSideScaling | Select ReceiveSideScaling -ExpandProperty ReceiveSideScaling | Out-String -Stream
if ($STATUSRSS -eq "Disabled")
{
Write-Host " The RECEIVE SIDE SCALING is already disabled, so nothing to do. :-)" -ForegroundColor Green
}
else
{
Write-Host " The RECEIVE SIDE SCALING is enabled, try next to disable it." -ForegroundColor Yellow
try
{
Set-NetOffloadGlobalSetting -ReceiveSideScaling Disabled -ErrorAction Stop
Write-Host " The RECEIVE SIDE SCALING is successfully set to disabled. :-)" -ForegroundColor Green
}
catch
{
$DISABLERSSOK = $false
Write-Host (" The RECEIVE SIDE SCALING could not set to disabled. :-(") -ForegroundColor Red
if ($DEDAILEDDEBUG -eq "ON")
{Write-Host $_ -ForegroundColor Red}
}
}
if ($DISABLERSSOK -eq $true)
{
Write-Host "Disabling RECEIVE SIDE SCALING has been finished successfully. :-)" -ForegroundColor Cyan
}
else
{
$FULLYCOMPLETED = $false
Write-Host "Disabling RECEIVE SIDE SCALING can't finished successfully. :-(" -ForegroundColor Red
}
}
else
{
Write-Host "Due to the installed Hyper-V role, the optimization of the RECEIVE SIDE SCALING on Windows TCP-Stack is skipped." -ForegroundColor Yellow
}
# DISABLE RECEIVE SEGMENT COALESCING ON WINDOWS TCP-STACK
$DISABLERSCOK = $true
Write-Host "Start disabling RECEIVE SEGMENT COALESCING on Windows TCP-Stack" -ForegroundColor Cyan
Write-Host " Check current state of RECEIVE SEGMENT COALESCING" -ForegroundColor Gray
$STATUSRSC = Get-NetOffloadGlobalSetting | Select-Object ReceiveSegmentCoalescing | Select ReceiveSegmentCoalescing -ExpandProperty ReceiveSegmentCoalescing | Out-String -Stream
if ($STATUSRSC -eq "Disabled")
{
Write-Host " The RECEIVE SEGMENT COALESCING is already disabled, so nothing to do. :-)" -ForegroundColor Green
}
else
{
Write-Host " The RECEIVE SEGMENT COALESCING is enabled, try next to disable it." -ForegroundColor Yellow
try
{
Set-NetOffloadGlobalSetting -ReceiveSegmentCoalescing Disabled -ErrorAction Stop
Write-Host " The RECEIVE SEGMENT COALESCING is successfully set to disabled. :-)" -ForegroundColor Green
}
catch
{
$DISABLERSCOK = $false
Write-Host (" The RECEIVE SEGMENT COALESCING could not set to disabled. :-(") -ForegroundColor Red
if ($DEDAILEDDEBUG -eq "ON")
{Write-Host $_ -ForegroundColor Red}
}
}
if ($DISABLERSCOK -eq $true)
{
Write-Host "Disabling RECEIVE SEGMENT COALESCING has been finished successfully. :-)" -ForegroundColor Cyan
}
else
{
$FULLYCOMPLETED = $false
Write-Host "Disabling RECEIVE SEGMENT COALESCING can't finished successfully. :-(" -ForegroundColor Red
}
# OPTIMIZE TCP CONGESTION CONTROL
$CHANGETCPCCOK = $true
Write-Host "Start TCP congestion control optimization" -ForegroundColor Cyan
Write-Host " Try to set the congestionprovider of the Internet TCP profile to DCTCP" -ForegroundColor Gray
try
{
$COMMANDOUTPUT = Invoke-Expression -Command "netsh int tcp set supplemental template=Internet congestionprovider=DCTCP" -ErrorAction Stop | Out-String -Stream
if ($COMMANDOUTPUT -eq "OK.")
{
Write-Host " Try to set the congestionprovider of the Internet TCP profile to DCTCP was successfully. :-)" -ForegroundColor Green
}
else
{
$CHANGETCPCCOK = $false
Write-Host " The Update of the congestionprovider of the Internet TCP profile to DCTCP was NOT successfully. :-(" -ForegroundColor Red
Write-Host (" " + $COMMANDOUTPUT) -ForegroundColor Red
}
}
catch
{
$CHANGETCPCCOK = $false
Write-Host (" The Update of the congestionprovider of the Internet TCP profile to DCTCP was NOT successfully. :-(") -ForegroundColor Red
if ($DEDAILEDDEBUG -eq "ON")
{Write-Host $_ -ForegroundColor Red}
}
Write-Host " Try to enable ECN" -ForegroundColor Gray
try
{
$COMMANDOUTPUT = Invoke-Expression -Command "netsh int tcp set global ECN=Enabled" -ErrorAction Stop | Out-String -Stream
if ($COMMANDOUTPUT -eq "OK.")
{
Write-Host " Enable ECN was successfully. :-)" -ForegroundColor Green
}
else
{
$CHANGETCPCCOK = $false
Write-Host " Try to enable ECN was NOT successfully. :-(" -ForegroundColor Red
Write-Host (" " + $COMMANDOUTPUT) -ForegroundColor Red
}
}
catch
{
$CHANGETCPCCOK = $false
Write-Host (" Try to enable ECN was NOT successfully was NOT successfully. :-(") -ForegroundColor Red
if ($DEDAILEDDEBUG -eq "ON")
{Write-Host $_ -ForegroundColor Red}
}
if ($CHANGETCPCCOK -eq $true)
{
Write-Host "TCP congestion control optimization is finished successfully. :-)" -ForegroundColor Cyan
}
else
{
$FULLYCOMPLETED = $false
Write-Host "TCP congestion control can't finished successfully. :-(" -ForegroundColor Red
}
# REMOVE TCP CONNECTION LIMIT
Write-Host "Start to remove the TCP connection limit." -ForegroundColor Cyan
$REMOVETCPCONNECTIONLIMITOK = $true
$REGKEYPATH = "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\" | Out-String -Stream
Write-Host (" Check if the key already exists in the registry.") -ForegroundColor Gray
$TARGETVALUE = 0
$CHECKVALUE = Get-ItemProperty -Path "$REGKEYPATH" -Name "EnableConnectionRateLimiting" -ErrorAction SilentlyContinue | Select-Object -ExpandProperty "EnableConnectionRateLimiting"
if (($CHECKVALUE -ne $null) -and ($CHECKVALUE.Length -gt 0))
{
Write-Host (" The key is present in the registry.") -ForegroundColor Yellow
Write-Host (" Checking the already existing key.") -ForegroundColor Gray
$AREEQUAL = @(Compare-Object $TARGETVALUE $CHECKVALUE -SyncWindow 0).Length -eq 0
if ($AREEQUAL -eq $true)
{
Write-Host (" The setting is already set correctly, no further measures are required.") -ForegroundColor Green
}
else
{
Write-Host " The current registry key does not match the desired value and therefore needs to be updated." -ForegroundColor Yellow
try
{
Set-ItemProperty -Path "$REGKEYPATH" -Name "EnableConnectionRateLimiting" -Value 0 -ErrorAction Stop
Write-Host " The corresponding registry entry has now been successfully updated." -ForegroundColor Green
}
catch
{
$REMOVETCPCONNECTIONLIMITOK = $false
Write-Host (" The registry key could not be updated due to an error. :-(") -ForegroundColor Red
if ($DEDAILEDDEBUG -eq "ON")
{Write-Host $_ -ForegroundColor Red}
}
}
}
else
{
Write-Host (" The corresponding registry key does not exist and is now being created.") -ForegroundColor Yellow
try
{
New-ItemProperty -Path "$REGKEYPATH" -Name "EnableConnectionRateLimiting" -PropertyType DWord -Value "0" -ErrorAction Stop
Write-Host (" The corresponding registry key for NIC " + $NICNAME + " has been created successfully. :-)") -ForegroundColor Green
}
catch
{
$CHANGETCPACKFREQUENCYOK = $false
Write-Host (" The registry key could not be created due to an error. :-(") -ForegroundColor Red
if ($DEDAILEDDEBUG -eq "ON")
{Write-Host $_ -ForegroundColor Red}
}
}
if ($REMOVETCPCONNECTIONLIMITOK -eq $true)
{
Write-Host "Removing the TCP connection limit is finished successfully. :-)" -ForegroundColor Cyan
}
else
{
$FULLYCOMPLETED = $false
Write-Host "Removing the TCP connection limit can't finished successfully. :-(" -ForegroundColor Red
}
# DISABLE RSS ON ALL NIC's
if ($HYPERVSTATE -eq "Disabled")
{
$DISABLERSSOK = $true
Write-Host "Start disabling RSS on all NIC's" -ForegroundColor Cyan
Write-Host " Check if NIC's with RSS support are available on this System." -ForegroundColor Gray
$NICs = Get-NetAdapter -Physical | Get-NetAdapterAdvancedProperty | Where-Object -FilterScript {$_.RegistryKeyword -Like "*RSS"}
$NICsWITHRSS = $NICs | Measure-Object -Line | Select-Object Lines | Select Lines -ExpandProperty Lines
if ($NICsWITHRSS -eq 0)
{
Write-Host (" No NIC's installed in this system which support RSS, so, nothing to do. :-)") -ForegroundColor Green
}
else
{
Write-Host (" " + $NICsWITHRSS + " NIC's found on this System that support RSS") -ForegroundColor Yellow
foreach ($adapter in $NICs)
{
$NICNAME = $adapter | Select-Object Name | Select Name -ExpandProperty Name | Out-String -Stream
$RSSVALUE = $adapter | Select-Object RegistryValue | Select RegistryValue -ExpandProperty RegistryValue | Out-String -Stream
Write-Host (" Check RSS Status of NIC " + $NICNAME + " .") -ForegroundColor Gray
if ($RSSVALUE -eq "0")
{
Write-Host (" RSS on NIC " + $NICNAME + " is already disabled, so, nothing to do. :-)") -ForegroundColor Green
}
else
{
Write-Host (" RSS on NIC " + $NICNAME + " is enabled, try next to disable it.") -ForegroundColor Yellow
try
{
Set-NetAdapterAdvancedProperty -Name "$NICNAME" -RegistryKeyword "*RSS" -RegistryValue 0 -ErrorAction Stop
Write-Host " RSS on NIC " + $NICNAME + ", has been successfully set to disabled. :-)" -ForegroundColor Green
}
catch
{
$DISABLERSSOK = $false
Write-Host (" The RSS on NIC " + $NICNAME + ", could not set to disabled. :-(") -ForegroundColor Red
if ($DEDAILEDDEBUG -eq "ON")
{Write-Host $_ -ForegroundColor Red}
}
}
}
}
if ($DISABLERSSOK -eq $true)
{
Write-Host "RSS has been successfully disabled on all corresponding NIC's or there is nothing to do. :-)" -ForegroundColor Cyan
}
else
{
$FULLYCOMPLETED = $false
Write-Host "Disabling RSS can't finished successfully. :-(" -ForegroundColor Red
}
}
else
{
Write-Host "Due to the installed Hyper-V role, DISABLE RSS ON ALL NIC's is skipped." -ForegroundColor Yellow
}
# DISABLE RSC-IPv4 FOR ALL NIC's
$DISABLERSCIPV4OK = $true
Write-Host "Start disabling RSC-IPv4 on all NIC's" -ForegroundColor Cyan
Write-Host " Check if NIC's with RSC-IPv4 support are available on this System." -ForegroundColor Gray
$NICs = Get-NetAdapter -Physical | Get-NetAdapterAdvancedProperty | Where-Object -FilterScript {$_.RegistryKeyword -Like "*RscIPv4"}
$NICsWITHRSCIPV4 = $NICs | Measure-Object -Line | Select-Object Lines | Select Lines -ExpandProperty Lines
if ($NICsWITHRSCIPV4 -eq 0)
{
Write-Host (" No NIC's installed in this system which support RSC-IPv4, so, nothing to do. :-)") -ForegroundColor Green
}
else
{
Write-Host (" " + $NICsWITHRSCIPV4 + " NIC's found on this System that support RSC-IPv4") -ForegroundColor Yellow
foreach ($adapter in $NICs)
{
$NICNAME = $adapter | Select-Object Name | Select Name -ExpandProperty Name | Out-String -Stream
$RSCVALUE = $adapter | Select-Object RegistryValue | Select RegistryValue -ExpandProperty RegistryValue | Out-String -Stream
Write-Host (" Check RSC-IPv4 Status of NIC " + $NICNAME + " .") -ForegroundColor Gray
if ($RSCVALUE -eq "0")
{
Write-Host (" RSC-IPv4 on NIC " + $NICNAME + " is already disabled, so, nothing to do. :-)") -ForegroundColor Green
}
else
{
Write-Host (" RSC-IPv4 on NIC " + $NICNAME + " is enabled, try next to disable it.") -ForegroundColor Yellow
try
{
Set-NetAdapterAdvancedProperty -Name "$NICNAME" -RegistryKeyword "*RscIPv4" -RegistryValue 0 -ErrorAction Stop
Write-Host " RSC-IPv4 on NIC " + $NICNAME + ", has been successfully set to disabled. :-)" -ForegroundColor Green
}
catch
{
$DISABLERSCIPV4OK = $false
Write-Host (" The RSC-IPv4 on NIC " + $NICNAME + ", could not set to disabled. :-(") -ForegroundColor Red
if ($DEDAILEDDEBUG -eq "ON")
{Write-Host $_ -ForegroundColor Red}
}
}
}
}
if ($DISABLERSCIPV4OK -eq $true)
{
Write-Host "RSC-IPv4 has been successfully disabled on all corresponding NIC's or there is nothing to do. :-)" -ForegroundColor Cyan
}
else
{
$FULLYCOMPLETED = $false
Write-Host "Disabling RSC-IPv4 can't finished successfully. :-(" -ForegroundColor Red
}
# DISABLE RSC-IPv6 FOR ALL NIC's
$DISABLERSCIPV6OK = $true
Write-Host "Start disabling RSC-IPv6 on all NIC's" -ForegroundColor Cyan
Write-Host " Check if NIC's with RSC-IPv6 support are available on this System." -ForegroundColor Gray
$NICs = Get-NetAdapter -Physical | Get-NetAdapterAdvancedProperty | Where-Object -FilterScript {$_.RegistryKeyword -Like "*RscIPv6"}
$NICsWITHRSCIPV6 = $NICs | Measure-Object -Line | Select-Object Lines | Select Lines -ExpandProperty Lines
if ($NICsWITHRSCIPV6 -eq 0)
{
Write-Host (" No NIC's installed in this system which support RSC-IPv6, so, nothing to do. :-)") -ForegroundColor Green
}
else
{
Write-Host (" " + $NICsWITHRSCIPV6 + " NIC's found on this System that support RSC-IPv6") -ForegroundColor Yellow
foreach ($adapter in $NICs)
{
$NICNAME = $adapter | Select-Object Name | Select Name -ExpandProperty Name | Out-String -Stream
$RSCVALUE = $adapter | Select-Object RegistryValue | Select RegistryValue -ExpandProperty RegistryValue | Out-String -Stream
Write-Host (" Check RSC-IPv6 Status of NIC " + $NICNAME + " .") -ForegroundColor Gray
if ($RSCVALUE -eq "0")
{
Write-Host (" RSC-IPv6 on NIC " + $NICNAME + " is already disabled, so, nothing to do. :-)") -ForegroundColor Green
}
else
{
Write-Host (" RSC-IPv6 on NIC " + $NICNAME + " is enabled, try next to disable it.") -ForegroundColor Yellow
try
{
Set-NetAdapterAdvancedProperty -Name "$NICNAME" -RegistryKeyword "*RscIPv6" -RegistryValue 0 -ErrorAction Stop
Write-Host " RSC-IPv6 on NIC " + $NICNAME + ", has been successfully set to disabled. :-)" -ForegroundColor Green
}
catch
{
$DISABLERSCIPV6OK = $false
Write-Host (" The RSC-IPv6 on NIC " + $NICNAME + ", could not set to disabled. :-(") -ForegroundColor Red
if ($DEDAILEDDEBUG -eq "ON")
{Write-Host $_ -ForegroundColor Red}
}
}
}
}
if ($DISABLERSCIPV6OK -eq $true)
{
Write-Host "RSC-IPv6 has been successfully disabled on all corresponding NIC's or there is nothing to do. :-)" -ForegroundColor Cyan
}
else
{
$FULLYCOMPLETED = $false
Write-Host "Disabling RSC-IPv6 can't finished successfully. :-(" -ForegroundColor Red
}
# DISABLE FLOW CONTROL ON ALL NIC's
Write-Host "Start disabling FLOW CONTROL on all NIC's" -ForegroundColor Cyan
Write-Host " Identify the NICs that actually support FLOW CONTROL." -ForegroundColor Gray
$NICs = Get-NetAdapter -Physical | Get-NetAdapterAdvancedProperty | Where-Object -FilterScript {$_.RegistryKeyword -Like "*FlowControl"}
$DISABLEFCOK = $true
foreach ($adapter in $NICs)
{
$NICNAME = $adapter | Select-Object Name | Select Name -ExpandProperty Name | Out-String -Stream
$EEEVALUE = $adapter | Select-Object RegistryValue | Select RegistryValue -ExpandProperty RegistryValue | Out-String -Stream
Write-Host (" Check FLOW CONTROL Status of NIC " + $NICNAME + " .") -ForegroundColor Gray
if ($EEEVALUE -eq "0")
{
Write-Host (" The FLOW CONTROL is already disabled on NIC " + $NICNAME + ", so, nothing to do. :-)") -ForegroundColor Green
}
else
{
Write-Host " The FLOW CONTROL is enabled on NIC " + $NICNAME + ", try next to disable it." -ForegroundColor Yellow
try
{
Set-NetAdapterAdvancedProperty -Name "$NICNAME" -RegistryKeyword "*FlowControl" -RegistryValue 0 -ErrorAction Stop
Write-Host " The FLOW CONTROL on NIC " + $NICNAME + ", has been successfully set to disabled. :-)" -ForegroundColor Green
}
catch
{
$DISABLEFCOK = $false
Write-Host (" The FLOW CONTROL on NIC " + $NICNAME + ", could not set to disabled. :-(") -ForegroundColor Red
if ($DEDAILEDDEBUG -eq "ON")
{Write-Host $_ -ForegroundColor Red}
}
}
}
if ($DISABLEFCOK -eq $true)
{
Write-Host "FLOW CONTROL has been successfully disabled on all corresponding NIC's. :-)" -ForegroundColor Cyan
}
else
{
$FULLYCOMPLETED = $false
Write-Host "Disabling FLOW CONTROL can't finished successfully. :-(" -ForegroundColor Red
}
# DISABLE INTERRUPT MODERATION ON ALL NIC's
Write-Host "Start disabling INTERRUPT MODERATION on all NIC's" -ForegroundColor Cyan
Write-Host " Identify the NICs that actually support INTERRUPT MODERATION." -ForegroundColor Gray
$NICs = Get-NetAdapter -Physical | Get-NetAdapterAdvancedProperty | Where-Object -FilterScript {$_.RegistryKeyword -Like "*InterruptModeration"}
$DISABLEIMOK = $true
foreach ($adapter in $NICs)
{
$NICNAME = $adapter | Select-Object Name | Select Name -ExpandProperty Name | Out-String -Stream
$EEEVALUE = $adapter | Select-Object RegistryValue | Select RegistryValue -ExpandProperty RegistryValue | Out-String -Stream
Write-Host (" Check INTERRUPT MODERATION Status of NIC " + $NICNAME + " .") -ForegroundColor Gray
if ($EEEVALUE -eq "0")
{
Write-Host (" The INTERRUPT MODERATION is already disabled on NIC " + $NICNAME + ", so, nothing to do. :-)") -ForegroundColor Green
}
else
{
Write-Host " The INTERRUPT MODERATION is enabled on NIC " + $NICNAME + ", try next to disable it." -ForegroundColor Yellow
try
{
Set-NetAdapterAdvancedProperty -Name "$NICNAME" -RegistryKeyword "*InterruptModeration" -RegistryValue 0 -ErrorAction Stop
Write-Host " The INTERRUPT MODERATION on NIC " + $NICNAME + ", has been successfully set to disabled. :-)" -ForegroundColor Green
}
catch
{
$DISABLEIMOK = $false
Write-Host (" The INTERRUPT MODERATION on NIC " + $NICNAME + ", could not set to disabled. :-(") -ForegroundColor Red
if ($DEDAILEDDEBUG -eq "ON")
{Write-Host $_ -ForegroundColor Red}
}
}
}
if ($DISABLEIMOK -eq $true)
{
Write-Host "INTERRUPT MODERATION has been successfully disabled on all corresponding NIC's. :-)" -ForegroundColor Cyan
}
else
{
$FULLYCOMPLETED = $false
Write-Host "Disabling INTERRUPT MODERATION can't finished successfully. :-(" -ForegroundColor Red
}
# DISABLE ENERGY-EFFICIENT-ETHERNET ON ALL NIC's
Write-Host "Start disabling ENERGY-EFFICIENT-ETHERNET on all NIC's" -ForegroundColor Cyan
Write-Host " Identify the NICs that actually support ENERGY-EFFICIENT-ETHERNET." -ForegroundColor Gray
$NICs = Get-NetAdapter -Physical | Get-NetAdapterAdvancedProperty | Where-Object -FilterScript {$_.RegistryKeyword -Like "*EEE"}
$DISABLEEEEEOK = $true
foreach ($adapter in $NICs)
{
$NICNAME = $adapter | Select-Object Name | Select Name -ExpandProperty Name | Out-String -Stream
$EEEVALUE = $adapter | Select-Object RegistryValue | Select RegistryValue -ExpandProperty RegistryValue | Out-String -Stream
Write-Host (" Check EEE Status of NIC " + $NICNAME + " .") -ForegroundColor Gray
if ($EEEVALUE -eq "0")
{
Write-Host (" The EEE is already disabled on NIC " + $NICNAME + ", so, nothing to do. :-)") -ForegroundColor Green
}
else
{
Write-Host " The EEE is enabled on NIC " + $NICNAME + ", try next to disable it." -ForegroundColor Yellow
try
{
Set-NetAdapterAdvancedProperty -Name "$NICNAME" -RegistryKeyword "*EEE" -RegistryValue 0 -ErrorAction Stop
Write-Host " The EEE on NIC " + $NICNAME + ", has been successfully set to disabled. :-)" -ForegroundColor Green
}
catch
{
$DISABLEEEEEOK = $false
Write-Host (" The EEE on NIC " + $NICNAME + ", could not set to disabled. :-(") -ForegroundColor Red
if ($DEDAILEDDEBUG -eq "ON")
{Write-Host $_ -ForegroundColor Red}
}
}
}
if ($DISABLEEEEEOK -eq $true)
{
Write-Host "ENERGY-EFFICIENT-ETHERNET has been successfully disabled on all corresponding NIC's. :-)" -ForegroundColor Cyan
}
else
{
$FULLYCOMPLETED = $false
Write-Host "Disabling ENERGY-EFFICIENT-ETHERNET can't finished successfully. :-(" -ForegroundColor Red
}
# OPTIMIZE RECEIVE-BUFFERS ON ALL NIC's
# Get-NetAdapterAdvancedProperty | Where-Object -FilterScript {$_.RegistryKeyword -Like "*ReceiveBuffers"}
$RECEIVEBUFFERSIZES = @(8192, 8184, 4096, 2048, 1024, 512, 256, 128)
Write-Host "Start Receive-Buffer optimization" -ForegroundColor Cyan
$NICs = Get-Netadapter -Physical | Get-NetAdapterAdvancedProperty | Where-Object -FilterScript {$_.RegistryKeyword -Like "*ReceiveBuffers"}
foreach ($adapter in $NICs)
{
$NICNAME = $adapter | Select-Object Name | Select Name -ExpandProperty Name | Out-String -Stream
$CHANGERBOK = "NO"
foreach ($RECEIVEBUFFESIZE in $RECEIVEBUFFERSIZES)
{
if ($CHANGERBOK -eq "NO")
{
Write-Host (" Try to set receive buffer size of NIC " + $NICNAME + " to " + $RECEIVEBUFFESIZE + "KB.") -ForegroundColor Gray
try
{
Set-NetAdapterAdvancedProperty -Name "$NICNAME" -RegistryKeyword "*ReceiveBuffers" -RegistryValue $RECEIVEBUFFESIZE -ErrorAction Stop
$CHANGERBOK = "YES"
Write-Host (" The receive buffer size of NIC " + $NICNAME + " was successfully configured to " + $RECEIVEBUFFESIZE + "KB. :-)") -ForegroundColor Green
}
catch
{
Write-Host (" Oops, the NIC " + $NICNAME + " does not accept a receive buffer size of " + $RECEIVEBUFFESIZE + "KB ... :-( ... never mind ... try with a smaller buffer next.") -ForegroundColor Yellow
$CHANGERBOK = "NO"
if ($DEDAILEDDEBUG -eq "ON")
{Write-Host $_ -ForegroundColor Red}
}
}
}
}
Write-Host "Receive-Buffer optimization is completely finished." -ForegroundColor Cyan
# OPTIMIZE TRANSMIT-BUFFERS ON ALL NIC's
# Get-NetAdapterAdvancedProperty | Where-Object -FilterScript {$_.RegistryKeyword -Like "*TransmitBuffers"}
$TRANSMITBUFFERSIZES = @(8192, 8184, 4096, 2048, 1024, 512, 256, 128)
Write-Host "Start Transmit-Buffer optimization" -ForegroundColor Cyan
$NICs = Get-Netadapter -Physical | Get-NetAdapterAdvancedProperty | Where-Object -FilterScript {$_.RegistryKeyword -Like "*TransmitBuffers"}
foreach ($adapter in $NICs)
{
$NICNAME = $adapter | Select-Object Name | Select Name -ExpandProperty Name | Out-String -Stream
$CHANGETBOK = "NO"
foreach ($TRANSMITBUFFESIZE in $TRANSMITBUFFERSIZES)
{
if ($CHANGETBOK -eq "NO")
{
Write-Host (" Try to set transmit buffer size of NIC " + $NICNAME + " to " + $TRANSMITBUFFESIZE + "KB.") -ForegroundColor Gray
try
{
Set-NetAdapterAdvancedProperty -Name "$NICNAME" -RegistryKeyword "*TransmitBuffers" -RegistryValue $TRANSMITBUFFESIZE -ErrorAction Stop
$CHANGETBOK = "YES"
Write-Host (" The transmit buffer size of NIC " + $NICNAME + " was successfully configured to " + $TRANSMITBUFFESIZE + "KB. :-)") -ForegroundColor Green
}
catch
{
Write-Host (" Oops, the NIC " + $NICNAME + " does not accept a transmit buffer size of " + $TRANSMITBUFFESIZE + "KB ... :-( ... never mind ... try with a smaller buffer next.") -ForegroundColor Yellow
$CHANGETBOK = "NO"
if ($DEDAILEDDEBUG -eq "ON")
{Write-Host $_ -ForegroundColor Red}
}
}
}
}
Write-Host "Transmit-Buffer optimization is completely finished." -ForegroundColor Cyan
# OPTIMIZE TCPACKFREQUENCY
Write-Host "Start ACK-Frequency optimization" -ForegroundColor Cyan
$NICs = Get-NetAdapter -Physical | Select-Object DeviceID, Name
$CHANGETCPACKFREQUENCYOK = $true
foreach ($adapter in $NICs)
{
$NICGUID = $adapter | Select-Object DeviceID | Select DeviceID -ExpandProperty DeviceID | Out-String -Stream
$NICNAME = $adapter | Select-Object Name | Select Name -ExpandProperty Name | Out-String -Stream
$REGKEYPATH = "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\$NICGUID\" | Out-String -Stream
Write-Host (" Check if the key already exists in the registry for NIC " + $NICNAME + " .") -ForegroundColor Gray
$TARGETVALUE = 1
$CHECKVALUE = Get-ItemProperty -Path "$REGKEYPATH" -Name "TcpAckFrequency" -ErrorAction SilentlyContinue | Select-Object -ExpandProperty "TcpAckFrequency"
if (($CHECKVALUE -ne $null) -and ($CHECKVALUE.Length -gt 0))
{
Write-Host (" The key for NIC " + $NICNAME + " is present in the registry.") -ForegroundColor Yellow
Write-Host (" Checking the already existing key of NIC " + $NICNAME + ".") -ForegroundColor Gray
$AREEQUAL = @(Compare-Object $TARGETVALUE $CHECKVALUE -SyncWindow 0).Length -eq 0
if ($AREEQUAL -eq $true)
{
Write-Host (" The settings of NIC " + $NICNAME + " are already set correctly, no further measures are required.") -ForegroundColor Green
}
else
{
Write-Host " The current registry key of NIC " + $NICNAME + " does not match the desired value and therefore needs to be updated." -ForegroundColor Yellow
try
{
Set-ItemProperty -Path "$REGKEYPATH" -Name "TcpAckFrequency" -Value 1 -ErrorAction Stop
Write-Host " The corresponding registry entry for NIC " + $NICNAME + " has now been successfully updated." -ForegroundColor Green
}
catch
{
$CHANGETCPACKFREQUENCYOK = $false
Write-Host (" The registry key for NIC " + $NICNAME + " could not be updated due to an error. :-(") -ForegroundColor Red
if ($DEDAILEDDEBUG -eq "ON")
{Write-Host $_ -ForegroundColor Red}
}
}
}
else
{
Write-Host (" The corresponding registry key for NIC " + $NICNAME + " does not exist and is now being created.") -ForegroundColor Yellow
try
{
New-ItemProperty -Path "$REGKEYPATH" -Name "TcpAckFrequency" -PropertyType DWord -Value "1" -ErrorAction Stop
Write-Host (" The corresponding registry key for NIC " + $NICNAME + " has been created successfully. :-)") -ForegroundColor Green
}
catch
{
$CHANGETCPACKFREQUENCYOK = $false
Write-Host (" The registry key could not be created due to an error. :-(") -ForegroundColor Red
if ($DEDAILEDDEBUG -eq "ON")
{Write-Host $_ -ForegroundColor Red}
}
}
}
if ($CHANGETCPACKFREQUENCYOK -eq $true)
{
Write-Host "ACK-Frequency optimization is finished successfully. :-)" -ForegroundColor Cyan
}
else
{
$FULLYCOMPLETED = $false
Write-Host "ACK-Frequency optimization can't finished successfully. :-(" -ForegroundColor Red
}
# OPTIMIZE TCPDELAY
Write-Host "Start TCP-Delay optimization" -ForegroundColor Cyan
$NICs = Get-NetAdapter -Physical | Select-Object DeviceID, Name
$CHANGETCPDELAYOK = $true
foreach ($adapter in $NICs)
{
$NICGUID = $adapter | Select-Object DeviceID | Select DeviceID -ExpandProperty DeviceID | Out-String -Stream
$NICNAME = $adapter | Select-Object Name | Select Name -ExpandProperty Name | Out-String -Stream
$REGKEYPATH = "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\$NICGUID\" | Out-String -Stream
Write-Host (" Check if the key already exists in the registry for NIC " + $NICNAME + " .") -ForegroundColor Gray
$TARGETVALUE = 1
$CHECKVALUE = Get-ItemProperty -Path "$REGKEYPATH" -Name "TcpNoDelay" -ErrorAction SilentlyContinue | Select-Object -ExpandProperty "TcpNoDelay"
if (($CHECKVALUE -ne $null) -and ($CHECKVALUE.Length -gt 0))
{
Write-Host (" The key for NIC " + $NICNAME + " is present in the registry.") -ForegroundColor Yellow
Write-Host (" Checking the already existing key of NIC " + $NICNAME + ".") -ForegroundColor Gray
$AREEQUAL = @(Compare-Object $TARGETVALUE $CHECKVALUE -SyncWindow 0).Length -eq 0
if ($AREEQUAL -eq $true)
{
Write-Host (" The settings of NIC " + $NICNAME + " are already set correctly, no further measures are required.") -ForegroundColor Green
}
else
{
Write-Host (" The current registry key of NIC " + $NICNAME + " does not match the desired value and therefore needs to be updated.") -ForegroundColor Yellow
try
{
Set-ItemProperty -Path "$REGKEYPATH" -Name "TcpNoDelay" -Value 1 -ErrorAction Stop
Write-Host (" The corresponding registry entry for NIC " + $NICNAME + " has now been successfully updated.") -ForegroundColor Green
}
catch
{
$CHANGETCPDELAYOK = $false
Write-Host (" The registry key for NIC " + $NICNAME + " could not be updated due to an error. :-(") -ForegroundColor Red
if ($DEDAILEDDEBUG -eq "ON")
{Write-Host $_ -ForegroundColor Red}
}
}
}
else
{
Write-Host (" The corresponding registry key for NIC " + $NICNAME + " does not exist and is now being created.") -ForegroundColor Yellow
try
{
New-ItemProperty -Path "$REGKEYPATH" -Name "TcpNoDelay" -PropertyType DWord -Value "1" -ErrorAction Stop
Write-Host (" The corresponding registry key for NIC " + $NICNAME + " has been created successfully. :-)") -ForegroundColor Green
}
catch
{
$CHANGETCPDELAYOK = $false
Write-Host (" The registry key could not be created due to an error. :-(") -ForegroundColor Red
if ($DEDAILEDDEBUG -eq "ON")
{Write-Host $_ -ForegroundColor Red}
}
}
}
if ($CHANGETCPDELAYOK -eq $true)
{
Write-Host "TCP-Delay optimization is finished successfully. :-)" -ForegroundColor Cyan
Write-Host "!!! To ensure that all changes are applied, the computer must be restarted. !!!" -ForegroundColor Magenta
}
else
{
$FULLYCOMPLETED = $false
Write-Host ("TCP-Delay optimization can't finished successfully. :-(") -ForegroundColor Red
Write-Host ("!!! And even if not everything went through cleanly, the computer should still be restarted so that at least what could be optimized works properly. ;-) !!!") -ForegroundColor Magenta
}
Write-Host (" ") -ForegroundColor White
Write-Host ("************************************************************************************************************") -ForegroundColor White
Write-Host ("*** End of change logging from " + $BAKLOGDATE) -ForegroundColor White
Write-Host ("************************************************************************************************************") -ForegroundColor White
Write-Host (" ") -ForegroundColor White
Stop-Transcript