1. 程式人生 > >Powershell 修改網卡配置腳本

Powershell 修改網卡配置腳本

批量修改客戶端網卡配置

$ComputerName = hostname
$OS_Version = (Get-WmiObject -class win32_operatingsystem -computer $ComputerName).version
$regPath = ‘HKLM:\SYSTEM\CurrentControlSet\Control\Class{4D36E972-E325-11CE-BFC1-08002BE10318}‘

Function Change-NetworkAdapterSettings()
{
Get-NetAdapterAdvancedProperty -DisplayName 首選頻帶 | set-NetAdapterAdvancedProperty -RegistryValue 2

}

Function UPdate-REGSettings()
{

Get-ChildItem $regPath| foreach { 

? $product =? Get-ItemProperty $_.PSPath
if($product.NetType -eq ‘WLAN‘ )
{
Set-ItemProperty $product.PSPath -Name "RoamingPreferredBandType" -Value 2
}
}
}

if (($OS_Version -like "6.*"))
{
write-host "Computer Name:"$ComputerName

write-host "OS:Windows 7"
UPdate-REGSettings

}
elseif ($OS_Version -like "10.*")
{
write-host "OS:Windows 10"
Change-NetworkAdapterSettings
}

Powershell 修改網卡配置腳本