我有一些Rackspace虚拟机,需要禁用这些高级NIC属性:
现在我需要使用Powershell / Batch来做到这一点,直到现在我有这个。
Disable-NetAdapterChecksumOffload -Name private -UdpIPv4 -TcpIPv4 Disable-NetAdapterLso -Name private cmd.exe /C "netsh int tcp set global chimney=disabled" cmd.exe /C "netsh int tcp set global rss=disabled" cmd.exe /C "netsh int tcp set global netdma=disabled" cmd.exe /C "netsh int ip set global taskoffload=disabled" new-ItemProperty -force -Path hklm:\\\\HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Services\\TCPIP\\Parameters -Name DisableTaskOffload -Value 1 new-ItemProperty -force -Path hklm:\\\\HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Services\\TCPIP\\Parameters -Name TCPChecksumOffloadIPv4 -Value 0 new-ItemProperty -force -Path hklm:\\\\HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Services\\TCPIP\\Parameters -Name UDPChecksumOffloadIPv4 -Value 0
但我不能让它工作。
我设法用这个PowerShell脚本来做到这一点。
$root = 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}' $items = Get-ChildItem -Path Registry::$Root -Name Foreach ($item in $items) { if ($item -ne "Properties") { $path = $root + "\" + $item $DriverDesc = Get-ItemProperty -Path Registry::$path | Select-Object -expandproperty DriverDesc if ($DriverDesc -eq "Citrix PV Ethernet Adapter") { Set-ItemProperty -path Registry::$path -Name LROIPv4 -Value 0 } } } new-ItemProperty -force -Path hklm:\\\\HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Services\\TCPIP\\Parameters -Name IPChecksumOffloadIPv4 -Value 0 new-ItemProperty -force -Path hklm:\\\\HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Services\\TCPIP\\Parameters -Name LSOv2IPv4 -Value 0 new-ItemProperty -force -Path hklm:\\\\HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Services\\TCPIP\\Parameters -Name NeedChecksumValue -Value 0 new-ItemProperty -force -Path hklm:\\\\HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Services\\TCPIP\\Parameters -Name TCPChecksumOffloadIPv4 -Value 0 new-ItemProperty -force -Path hklm:\\\\HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Services\\TCPIP\\Parameters -Name UDPChecksumOffloadIPv4 -Value 0 new-ItemProperty -force -Path hklm:\\\\HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Services\\TCPIP\\Parameters -Name LROIPv4 -Value 0
其重要的是要看到属性被改变。
使用:
PS > Get-NetAdapter PS > Get-NetAdapterAdvancedProperty name_of_the_nic PS > Get-NetAdapterAdvancedProperty name_of_the_nic | ft RegistryKeyword
现在根据需要更新RegistryKeyword
假设“以太网”是您的网卡的名称:
# Display valid values Get-NetAdapterAdvancedProperty Ethernet | ft DisplayName , ValidDisplayValues # Display existing settings: Get-NetAdapterAdvancedProperty Ethernet | ft DisplayName, DisplayValue, RegistryKeyword , RegistryValue # Set all the settings required to switch of TCP IPv4 offloading to fix SQL Server connection dropouts in high connection, high transaction environment: # Note that RDP connection to instance will drop out momentarily Set-NetAdapterAdvancedProperty Ethernet -DisplayName "IPv4 Checksum Offload" -DisplayValue "Disabled" -NoRestart Set-NetAdapterAdvancedProperty Ethernet -DisplayName "Large Send Offload V2 (IPv4)" -DisplayValue "Disabled" -NoRestart Set-NetAdapterAdvancedProperty Ethernet -DisplayName "TCP Checksum Offload (IPv4)" -DisplayValue "Disabled" -NoRestart Set-NetAdapterAdvancedProperty Ethernet -DisplayName "Large Receive Offload (IPv4)" -DisplayValue "Disabled" # Check its worked Get-NetAdapterAdvancedProperty Ethernet | ft DisplayName, DisplayValue, RegistryKeyword , RegistryValue