21 April 2016

NIC Advanced Properties

Recently, we started having issues with our new Dell Latitude E7450 laptops. They would be put to sleep and then they could not restore the network connection once the laptop was docked again. The problem came from the Energy Efficient Ethernet setting in the advanced properties of the NIC. That is what lead me to writing this script so that we could set it during the build process. With the help of Sapien Technology's PowerShell Studio, this was pretty easy to write and it made writing the code very thorough.

I wrote the script so that all entries are there, at least for the Dell models we use. You may need to manually add or delete some values if the systems you have differ, which they likely will. I set the script up so that unless there are values that need to be entered, everything can be done from command line. If you do not define a parameter, then it is skipped over. I entered the exact values from the drop-down menus for each value. The script translates that into the required value to enter into the registry. I also put the possible values within the comments of each parameter.

You can download the script from here.


1:  <#  
2:       .SYNOPSIS  
3:            NIC Advanced Properties  
4:         
5:       .DESCRIPTION  
6:            Configure NIC Advanced Properties by modifying the values in the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318} registry key.  
7:         
8:       .PARAMETER ConsoleTitle  
9:            Title displayed in the PowerShell Console  
10:         
11:       .PARAMETER EnergyEfficientEthernet  
12:            RegValue: EEELinkAdvertisement  
13:            0 - Off  
14:            1 - On  
15:         
16:       .PARAMETER FlowControl  
17:            RegValue: *FlowControl  
18:            0 - Disabled  
19:            1 - Tx Enabled  
20:            2 - Rx Enabled  
21:            3 - Rx & Tx Enabled  
22:         
23:       .PARAMETER JumboPacket  
24:            RegValue: *JumboPacket  
25:            1514 - Disabled  
26:            4088 - 4088 Bytes  
27:            9014 - 9014 Bytes  
28:         
29:       .PARAMETER LegacySwitchCompatibilityMode  
30:            RegValue: LinkNegotiationProcess  
31:            1 - Disabled  
32:            2 - Enabled  
33:         
34:       .PARAMETER LinkSpeedBatterySaver  
35:            RegValue: AutoPowerSaveModeEnabled  
36:            0 - Disabled  
37:            1 - Enabled  
38:         
39:       .PARAMETER PriorityVLAN  
40:            RegValue: *PriorityVLANTag  
41:            0 - Priority & VLAN Disabled  
42:            1 - Priority Enabled  
43:            2 - VLAN Enabled  
44:            3 - Priority & VLAN Enabled  
45:         
46:       .PARAMETER ProtocolARPOffload  
47:            RegValue: *PMARPOffload  
48:            0x00000000 - Enabled  
49:            0x00000001 - Disabled  
50:         
51:       .PARAMETER ProtocolNSOffload  
52:            RegValue: *PMNSOffload  
53:            0x00000000 - Enabled  
54:            0x00000001 - Disabled  
55:         
56:       .PARAMETER SpeedDuplex  
57:            RegValue: *SpeedDuplex  
58:            0 - Auto Negotiation  
59:            1 - 10 Mbps Half Duplex  
60:            2 - 10 Mbps Full Duplex  
61:            3 - 100 Mbps Half Duplex  
62:            4 - 100 Mbps Full Duplex  
63:            6 - 1.0 Gbps Full Duplex  
64:         
65:       .PARAMETER SystemIdlePowerSaver  
66:            RegValue: SipsEnabled  
67:            0 - Disabled  
68:            1 - Enabled  
69:         
70:       .PARAMETER WakeOnMagicPacket  
71:            RegValue: *WakeOnMagicPacket  
72:            0x00000000 - Enabled  
73:            0x00000001 - Disabled  
74:         
75:       .PARAMETER WakeOnPatternMatch  
76:            RegValue: *WakeOnPattern  
77:            0x00000000 - Enabled  
78:            0x00000001 - Disabled  
79:         
80:       .NOTES  
81:            ===========================================================================  
82:            Created with:      SAPIEN Technologies, Inc., PowerShell Studio 2016 v5.2.119  
83:            Created on:       4/20/2016 11:20 AM  
84:            Created by:          Mick Pletcher  
85:            Organization:  
86:            Filename:          NICAdvancedProperties  
87:            ===========================================================================  
88:  #>  
89:  [CmdletBinding()]  
90:  param  
91:  (  
92:            [string]$ConsoleTitle = 'NIC Advanced Properties',  
93:            [ValidateSet('Off', 'On')][string]$EnergyEfficientEthernet,  
94:            [ValidateSet('Disabled', 'Tx Enabled', 'Rx Enabled', 'Rx & Tx Enabled')][string]$FlowControl,  
95:            [ValidateSet('Disabled', '4088 Bytes', '9014 Bytes')][string]$JumboPacket,  
96:            [ValidateSet('Disabled', 'Enabled')][string]$LegacySwitchCompatibilityMode,  
97:            [ValidateSet('Disabled', 'Enabled')][string]$LinkSpeedBatterySaver,  
98:            [ValidateSet('Priority & VLAN Disabled', 'Priority Enabled', 'VLAN Enabled', 'Priority & VLAN Enabled')][string]$PriorityVLAN,  
99:            [ValidateSet('Disabled', 'Enabled')][string]$ProtocolARPOffload,  
100:            [ValidateSet('Disabled', 'Enabled')][string]$ProtocolNSOffload,  
101:            [ValidateSet('Auto Negotiation', '10 Mbps Half Duplex', '10 Mbps Full Duplex', '100 Mbps Half Duplex', '100 Mbps Full Duplex', '1.0 Gbps Full Duplex')][string]$SpeedDuplex,  
102:            [ValidateSet('Disabled', 'Enabled')][string]$SystemIdlePowerSaver,  
103:            [ValidateSet('Disabled', 'Enabled')][string]$WakeOnMagicPacket,  
104:            [ValidateSet('Disabled', 'Enabled')][string]$WakeOnPatternMatch  
105:  )  
106:    
107:  function Get-PhysicalNICs {  
108:  <#  
109:       .SYNOPSIS  
110:            Retrieve the Physical NICs  
111:         
112:       .DESCRIPTION  
113:            Find the physical NICs that are currently being used and return the information from the function  
114:         
115:       .EXAMPLE  
116:            PS C:\> Get-PhysicalNICs  
117:         
118:       .NOTES  
119:            Additional information about the function.  
120:  #>  
121:         
122:       [CmdletBinding()]  
123:       param ()  
124:         
125:       # Get all physical ethernet adaptors  
126:       $NICs = Get-WmiObject Win32_NetworkAdapter -filter "AdapterTypeID = '0' `  
127:       AND PhysicalAdapter = 'true' `  
128:       AND NOT Description LIKE '%Centrino%' `  
129:       AND NOT Description LIKE '%wireless%' `  
130:       AND NOT Description LIKE '%virtual%' `  
131:       AND NOT Description LIKE '%WiFi%' `  
132:       AND NOT Description LIKE '%Bluetooth%'"  
133:       Return $NICs  
134:  }  
135:    
136:  function Get-Platform {  
137:  <#  
138:       .SYNOPSIS  
139:            Determine Platform  
140:         
141:       .DESCRIPTION  
142:            Test if system is a desktop or laptop  
143:         
144:       .NOTES  
145:            Additional information about the function.  
146:  #>  
147:         
148:       [CmdletBinding()][OutputType([string])]  
149:       param ()  
150:         
151:       if (Get-WmiObject -Class win32_battery -ComputerName "localhost") {  
152:            $Platform = "Laptop"  
153:       } else {  
154:            $Platform = "Desktop"  
155:       }  
156:       Return $Platform  
157:  }  
158:    
159:  function Set-NICRegistryKey {  
160:  <#  
161:       .SYNOPSIS  
162:            Get registry key of NIC  
163:         
164:       .DESCRIPTION  
165:            Find the registry key of the physical NIC  
166:         
167:       .PARAMETER NetworkAdapters  
168:            List of physical NIC cards  
169:         
170:       .EXAMPLE  
171:            PS C:\> Set-NICRegistryKey  
172:         
173:       .NOTES  
174:            Additional information about the function.  
175:  #>  
176:         
177:       [CmdletBinding()]  
178:       param  
179:       (  
180:                 $NetworkAdapters  
181:       )  
182:         
183:       $NetworkAdapterKey = "HKLM:\system\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}"  
184:       foreach ($NetworkAdapter in $NetworkAdapters) {  
185:            If ([int]$NetworkAdapter.DeviceID -lt 10) {  
186:                 $NetworkAdapterSubKey = $NetworkAdapterKey + "\" + "000" + $NetworkAdapter.DeviceID  
187:            } else {  
188:                 $NetworkAdapterSubKey = $NetworkAdapterKey + "\" + "00" + $NetworkAdapter.DeviceID  
189:            }  
190:            $AdapterProperties = Get-ItemProperty $NetworkAdapterSubKey  
191:            #Energy Efficient Ethernet  
192:            If ($EnergyEfficientEthernet -ne "") {  
193:                 $AdaptorProperty = 'EEELinkAdvertisement'  
194:                 Write-Host "Energy Efficient Ethernet....." -NoNewline  
195:                 If ($EnergyEfficientEthernet -eq "On") {  
196:                      $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
197:                      Set-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty -Value 1  
198:                      $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
199:                      If ($Value.$AdaptorProperty -eq 1) {  
200:                           Write-Host $EnergyEfficientEthernet -ForegroundColor Yellow  
201:                      } else {  
202:                           Write-Host "Failed" -ForegroundColor Red  
203:                      }  
204:                 } else {  
205:                      $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
206:                      Set-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty -Value 0  
207:                      $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
208:                      If ($Value.$AdaptorProperty -eq 0) {  
209:                           Write-Host $EnergyEfficientEthernet -ForegroundColor Yellow  
210:                      } else {  
211:                           Write-Host "Failed" -ForegroundColor Red  
212:                      }  
213:                 }  
214:            }  
215:            #Flow Control  
216:            If ($FlowControl -ne "") {  
217:                 $AdaptorProperty = '*FlowControl'  
218:                 Write-Host "Flow Control....." -NoNewline  
219:                 switch ($FlowControl) {  
220:                      "Disabled" {  
221:                           $AdapterPropertyValue = 0  
222:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
223:                           Set-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty -Value $AdapterPropertyValue  
224:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
225:                           If ($Value.$AdaptorProperty -eq $AdapterPropertyValue) {  
226:                                Write-Host $FlowControl -ForegroundColor Yellow  
227:                           } else {  
228:                                Write-Host "Failed" -ForegroundColor Red  
229:                           }  
230:                      }  
231:                      "Tx Enabled" {  
232:                           $AdapterPropertyValue = 1  
233:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
234:                           Set-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty -Value $AdapterPropertyValue  
235:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
236:                           If ($Value.$AdaptorProperty -eq $AdapterPropertyValue) {  
237:                                Write-Host $FlowControl -ForegroundColor Yellow  
238:                           } else {  
239:                                Write-Host "Failed" -ForegroundColor Red  
240:                           }  
241:                      }  
242:                      "Rx Enabled" {  
243:                           $AdapterPropertyValue = 2  
244:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
245:                           Set-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty -Value $AdapterPropertyValue  
246:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
247:                           If ($Value.$AdaptorProperty -eq $AdapterPropertyValue) {  
248:                                Write-Host $FlowControl -ForegroundColor Yellow  
249:                           } else {  
250:                                Write-Host "Failed" -ForegroundColor Red  
251:                           }  
252:                      }  
253:                      "Rx & Tx Enabled" {  
254:                           $AdapterPropertyValue = 3  
255:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
256:                           Set-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty -Value $AdapterPropertyValue  
257:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
258:                           If ($Value.$AdaptorProperty -eq $AdapterPropertyValue) {  
259:                                Write-Host $FlowControl -ForegroundColor Yellow  
260:                           } else {  
261:                                Write-Host "Failed" -ForegroundColor Red  
262:                           }  
263:                      }  
264:                 }  
265:            }  
266:            #Jumbo Packet  
267:            If ($JumboPacket -ne "") {  
268:                 $AdaptorProperty = '*JumboPacket'  
269:                 Write-Host "Jumbo Packet....." -NoNewline  
270:                 switch ($JumboPacket) {  
271:                      "Disabled" {  
272:                           $AdapterPropertyValue = 1514  
273:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
274:                           Set-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty -Value $AdapterPropertyValue  
275:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
276:                           If ($Value.$AdaptorProperty -eq $AdapterPropertyValue) {  
277:                                Write-Host $JumboPacket -ForegroundColor Yellow  
278:                           } else {  
279:                                Write-Host "Failed" -ForegroundColor Red  
280:                           }  
281:                      }  
282:                      "4088 Bytes" {  
283:                           $AdapterPropertyValue = 4088  
284:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
285:                           Set-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty -Value $AdapterPropertyValue  
286:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
287:                           If ($Value.$AdaptorProperty -eq $AdapterPropertyValue) {  
288:                                Write-Host $JumboPacket -ForegroundColor Yellow  
289:                           } else {  
290:                                Write-Host "Failed" -ForegroundColor Red  
291:                           }  
292:                      }  
293:                      "9014 Bytes" {  
294:                           $AdapterPropertyValue = 9014  
295:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
296:                           Set-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty -Value $AdapterPropertyValue  
297:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
298:                           If ($Value.$AdaptorProperty -eq $AdapterPropertyValue) {  
299:                                Write-Host $JumboPacket -ForegroundColor Yellow  
300:                           } else {  
301:                                Write-Host "Failed" -ForegroundColor Red  
302:                           }  
303:                      }  
304:                 }  
305:            }  
306:            #Legacy Switch Compatibility Mode  
307:            If ($LegacySwitchCompatibilityMode -ne "") {  
308:                 $AdaptorProperty = 'LinkNegotiationProcess'  
309:                 Write-Host "Legacy Switch Compatibility Mode....." -NoNewline  
310:                 If ($LegacySwitchCompatibilityMode -eq "Disabled") {  
311:                      $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
312:                      Set-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty -Value 1  
313:                      $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
314:                      If ($Value.$AdaptorProperty -eq 1) {  
315:                           Write-Host $LegacySwitchCompatibilityMode -ForegroundColor Yellow  
316:                      } else {  
317:                           Write-Host "Failed" -ForegroundColor Red  
318:                      }  
319:                 } else {  
320:                      $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
321:                      Set-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty -Value 2  
322:                      $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
323:                      If ($Value.$AdaptorProperty -eq 2) {  
324:                           Write-Host $LegacySwitchCompatibilityMode -ForegroundColor Yellow  
325:                      } else {  
326:                           Write-Host "Failed" -ForegroundColor Red  
327:                      }  
328:                 }  
329:            }  
330:            #Link Speed Battery Saver  
331:            If ($LinkSpeedBatterySaver -ne "") {  
332:                 $Platform = Get-Platform  
333:                 If ($Platform -eq "Laptop") {  
334:                      $AdaptorProperty = 'AutoPowerSaveModeEnabled'  
335:                      Write-Host "Link Speed Battery Saver....." -NoNewline  
336:                      If ($LinkSpeedBatterySaver -eq "Disabled") {  
337:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
338:                           Set-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty -Value 0  
339:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
340:                           If ($Value.$AdaptorProperty -eq 0) {  
341:                                Write-Host $LinkSpeedBatterySaver -ForegroundColor Yellow  
342:                           } else {  
343:                                Write-Host "Failed" -ForegroundColor Red  
344:                           }  
345:                      } else {  
346:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
347:                           Set-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty -Value 1  
348:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
349:                           If ($Value.$AdaptorProperty -eq 1) {  
350:                                Write-Host $LinkSpeedBatterySaver -ForegroundColor Yellow  
351:                           } else {  
352:                                Write-Host "Failed" -ForegroundColor Red  
353:                           }  
354:                      }  
355:                 }  
356:            }  
357:            #Priority VLAN  
358:            If ($PriorityVLAN -ne "") {  
359:                 $AdaptorProperty = '*PriorityVLANTag'  
360:                 Write-Host "Priority VLAN....." -NoNewline  
361:                 switch ($PriorityVLAN) {  
362:                      "Priority & VLAN Disabled" {  
363:                           $AdapterPropertyValue = 0  
364:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
365:                           Set-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty -Value $AdapterPropertyValue  
366:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
367:                           If ($Value.$AdaptorProperty -eq $AdapterPropertyValue) {  
368:                                Write-Host $PriorityVLAN -ForegroundColor Yellow  
369:                           } else {  
370:                                Write-Host "Failed" -ForegroundColor Red  
371:                           }  
372:                      }  
373:                      "Priority Enabled" {  
374:                           $AdapterPropertyValue = 1  
375:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
376:                           Set-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty -Value $AdapterPropertyValue  
377:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
378:                           If ($Value.$AdaptorProperty -eq $AdapterPropertyValue) {  
379:                                Write-Host $PriorityVLAN -ForegroundColor Yellow  
380:                           } else {  
381:                                Write-Host "Failed" -ForegroundColor Red  
382:                           }  
383:                      }  
384:                      "VLAN Enabled" {  
385:                           $AdapterPropertyValue = 2  
386:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
387:                           Set-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty -Value $AdapterPropertyValue  
388:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
389:                           If ($Value.$AdaptorProperty -eq $AdapterPropertyValue) {  
390:                                Write-Host $PriorityVLAN -ForegroundColor Yellow  
391:                           } else {  
392:                                Write-Host "Failed" -ForegroundColor Red  
393:                           }  
394:                      }  
395:                      "Priority & VLAN Enabled" {  
396:                           $AdapterPropertyValue = 3  
397:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
398:                           Set-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty -Value $AdapterPropertyValue  
399:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
400:                           If ($Value.$AdaptorProperty -eq $AdapterPropertyValue) {  
401:                                Write-Host $PriorityVLAN -ForegroundColor Yellow  
402:                           } else {  
403:                                Write-Host "Failed" -ForegroundColor Red  
404:                           }  
405:                      }  
406:                 }  
407:            }  
408:            #Protocol ARP Offload  
409:            If ($ProtocolARPOffload -ne "") {  
410:                 $AdaptorProperty = '*PMARPOffload'  
411:                 Write-Host "Protocol ARP Offload....." -NoNewline  
412:                 If ($ProtocolARPOffload -eq "Disabled") {  
413:                      $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
414:                      Set-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty -Value 0x00000001  
415:                      $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
416:                      If ($Value.$AdaptorProperty -eq 0x00000001) {  
417:                           Write-Host $ProtocolARPOffload -ForegroundColor Yellow  
418:                      } else {  
419:                           Write-Host "Failed" -ForegroundColor Red  
420:                      }  
421:                 } else {  
422:                      $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
423:                      Set-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty -Value 0x00000000  
424:                      $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
425:                      If ($Value.$AdaptorProperty -eq 0x00000000) {  
426:                           Write-Host $ProtocolARPOffload -ForegroundColor Yellow  
427:                      } else {  
428:                           Write-Host "Failed" -ForegroundColor Red  
429:                      }  
430:                 }  
431:            }  
432:            #Protocol NS Offload  
433:            If ($ProtocolNSOffload -ne "") {  
434:                 $AdaptorProperty = '*PMNSOffload'  
435:                 Write-Host "Protocol NS Offload....." -NoNewline  
436:                 If ($ProtocolNSOffload -eq "Disabled") {  
437:                      $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
438:                      Set-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty -Value 0x00000001  
439:                      $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
440:                      If ($Value.$AdaptorProperty -eq 0x00000001) {  
441:                           Write-Host $ProtocolNSOffload -ForegroundColor Yellow  
442:                      } else {  
443:                           Write-Host "Failed" -ForegroundColor Red  
444:                      }  
445:                 } else {  
446:                      $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
447:                      Set-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty -Value 0x00000000  
448:                      $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
449:                      If ($Value.$AdaptorProperty -eq 0x00000000) {  
450:                           Write-Host $ProtocolNSOffload -ForegroundColor Yellow  
451:                      } else {  
452:                           Write-Host "Failed" -ForegroundColor Red  
453:                      }  
454:                 }  
455:            }  
456:            #Speed Duplex  
457:            if ($SpeedDuplex -ne "") {  
458:                 $AdaptorProperty = '*SpeedDuplex'  
459:                 $AdapterProperties.$AdaptorProperty = $SpeedDuplex  
460:            }  
461:            If ($SpeedDuplex -ne "") {  
462:                 $AdaptorProperty = '*SpeedDuplex'  
463:                 Write-Host "Speed Duplex....." -NoNewline  
464:                 switch ($SpeedDuplex) {  
465:                      "Auto Negotiation" {  
466:                           $AdapterPropertyValue = 0  
467:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
468:                           Set-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty -Value $AdapterPropertyValue  
469:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
470:                           If ($Value.$AdaptorProperty -eq $AdapterPropertyValue) {  
471:                                Write-Host $SpeedDuplex -ForegroundColor Yellow  
472:                           } else {  
473:                                Write-Host "Failed" -ForegroundColor Red  
474:                           }  
475:                      }  
476:                      "10 Mbps Half Duplex" {  
477:                           $AdapterPropertyValue = 1  
478:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
479:                           Set-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty -Value $AdapterPropertyValue  
480:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
481:                           If ($Value.$AdaptorProperty -eq $AdapterPropertyValue) {  
482:                                Write-Host $SpeedDuplex -ForegroundColor Yellow  
483:                           } else {  
484:                                Write-Host "Failed" -ForegroundColor Red  
485:                           }  
486:                      }  
487:                      "10 Mbps Full Duplex" {  
488:                           $AdapterPropertyValue = 2  
489:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
490:                           Set-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty -Value $AdapterPropertyValue  
491:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
492:                           If ($Value.$AdaptorProperty -eq $AdapterPropertyValue) {  
493:                                Write-Host $SpeedDuplex -ForegroundColor Yellow  
494:                           } else {  
495:                                Write-Host "Failed" -ForegroundColor Red  
496:                           }  
497:                      }  
498:                      "100 Mbps Half Duplex" {  
499:                           $AdapterPropertyValue = 3  
500:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
501:                           Set-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty -Value $AdapterPropertyValue  
502:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
503:                           If ($Value.$AdaptorProperty -eq $AdapterPropertyValue) {  
504:                                Write-Host $SpeedDuplex -ForegroundColor Yellow  
505:                           } else {  
506:                                Write-Host "Failed" -ForegroundColor Red  
507:                           }  
508:                      }  
509:                      "100 Mbps Full Duplex" {  
510:                           $AdapterPropertyValue = 4  
511:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
512:                           Set-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty -Value $AdapterPropertyValue  
513:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
514:                           If ($Value.$AdaptorProperty -eq $AdapterPropertyValue) {  
515:                                Write-Host $SpeedDuplex -ForegroundColor Yellow  
516:                           } else {  
517:                                Write-Host "Failed" -ForegroundColor Red  
518:                           }  
519:                      }  
520:                      "1.0 Gbps Full Duplex" {  
521:                           $AdapterPropertyValue = 6  
522:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
523:                           Set-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty -Value $AdapterPropertyValue  
524:                           $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
525:                           If ($Value.$AdaptorProperty -eq $AdapterPropertyValue) {  
526:                                Write-Host $SpeedDuplex -ForegroundColor Yellow  
527:                           } else {  
528:                                Write-Host "Failed" -ForegroundColor Red  
529:                           }  
530:                      }  
531:                 }  
532:            }  
533:            #System Idle Power Saver  
534:            If ($SystemIdlePowerSaver -ne "") {  
535:                 $AdaptorProperty = 'SipsEnabled'  
536:                 Write-Host "System Idle Power Saver....." -NoNewline  
537:                 If ($SystemIdlePowerSaver -eq "Enabled") {  
538:                      $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
539:                      Set-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty -Value 1  
540:                      $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
541:                      If ($Value.$AdaptorProperty -eq 1) {  
542:                           Write-Host $SystemIdlePowerSaver -ForegroundColor Yellow  
543:                      } else {  
544:                           Write-Host "Failed" -ForegroundColor Red  
545:                      }  
546:                 } else {  
547:                      $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
548:                      Set-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty -Value 0  
549:                      $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
550:                      If ($Value.$AdaptorProperty -eq 0) {  
551:                           Write-Host $SystemIdlePowerSaver -ForegroundColor Yellow  
552:                      } else {  
553:                           Write-Host "Failed" -ForegroundColor Red  
554:                      }  
555:                 }  
556:            }  
557:            #Wake On Magic Packet  
558:            If ($WakeOnMagicPacket -ne "") {  
559:                 $AdaptorProperty = '*WakeOnMagicPacket'  
560:                 Write-Host "Wake On Magic Packet....." -NoNewline  
561:                 If ($WakeOnMagicPacket -eq "Disabled") {  
562:                      $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
563:                      Set-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty -Value 0x00000001  
564:                      $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
565:                      If ($Value.$AdaptorProperty -eq 0x00000001) {  
566:                           Write-Host $WakeOnMagicPacket -ForegroundColor Yellow  
567:                      } else {  
568:                           Write-Host "Failed" -ForegroundColor Red  
569:                      }  
570:                 } else {  
571:                      $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
572:                      Set-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty -Value 0x00000000  
573:                      $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
574:                      If ($Value.$AdaptorProperty -eq 0x00000000) {  
575:                           Write-Host $WakeOnMagicPacket -ForegroundColor Yellow  
576:                      } else {  
577:                           Write-Host "Failed" -ForegroundColor Red  
578:                      }  
579:                 }  
580:            }  
581:            #Wake On Pattern Match  
582:            If ($WakeOnPatternMatch -ne "") {  
583:                 $AdaptorProperty = '*WakeOnPattern'  
584:                 Write-Host "Wake On Pattern Match....." -NoNewline  
585:                 If ($WakeOnPatternMatch -eq "Disabled") {  
586:                      $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
587:                      Set-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty -Value 0x00000001  
588:                      $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
589:                      If ($Value.$AdaptorProperty -eq 0x00000001) {  
590:                           Write-Host $WakeOnPatternMatch -ForegroundColor Yellow  
591:                      } else {  
592:                           Write-Host "Failed" -ForegroundColor Red  
593:                      }  
594:                 } else {  
595:                      $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
596:                      Set-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty -Value 0x00000000  
597:                      $Value = Get-ItemProperty -Path $NetworkAdapterSubKey -Name $AdaptorProperty  
598:                      If ($Value.$AdaptorProperty -eq 0x00000000) {  
599:                           Write-Host $WakeOnPatternMatch -ForegroundColor Yellow  
600:                      } else {  
601:                           Write-Host "Failed" -ForegroundColor Red  
602:                      }  
603:                 }  
604:            }  
605:       }  
606:  }  
607:    
608:  function Set-ConsoleTitle {  
609:  <#  
610:       .SYNOPSIS  
611:            Console Title  
612:         
613:       .DESCRIPTION  
614:            Sets the title of the PowerShell Console  
615:         
616:       .PARAMETER ConsoleTitle  
617:            Title of the PowerShell Console  
618:         
619:       .NOTES  
620:            Additional information about the function.  
621:  #>  
622:         
623:       [CmdletBinding()]  
624:       param  
625:       (  
626:                 [Parameter(Mandatory = $true)][String]$ConsoleTitle  
627:       )  
628:         
629:       $host.ui.RawUI.WindowTitle = $ConsoleTitle  
630:  }  
631:    
632:  Clear-Host  
633:  Set-ConsoleTitle $ConsoleTitle  
634:  $NICs = Get-PhysicalNICs  
635:  Set-NICRegistryKey -NetworkAdapters $NICs  
636:    

0 comments:

Post a Comment