Powershell 修改网卡配置脚本

时间:2018-04-07 17:35:16   收藏:0   阅读:1016
$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
}

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!