powershell 脚本设置DNS

#!powershell
$adapter = Get-NetAdapter |?{$_.InterfaceDescription -ne "Microsoft KM-TEST Loopback Adapter"}
if ($adapter -ne $null) 
{
    $adapter | Rename-NetAdapter -NewName "Eth"
     disable-NetAdapterBinding -Name "Eth" -ComponentID ms_tcpip6
     netsh interface ipv4 set dns name="Eth" source=static address=114.114.114.114 primary
     netsh interface ipv4 add dnsserver name="Eth" address=8.8.8.8 index=2
     netsh interface ipv4 add dnsserver name="Eth" address=202.96.209.133 index=3
}

以上就是powershell设置dns地址的脚本,适用于powershell 4及以上版本

windwos 2008 更改DNS方法:

$wmi=get-wmiobject -class win32_networkadapterconfiguration -filter ipenabled=true -computername 计算机名
$wmi.SetDNSServerSearchOrder(‘8.8.8.8‘)
时间: 2024-08-28 12:12:06

powershell 脚本设置DNS的相关文章

设置DNS域名服务器地址BAT批处理脚本文件.bat

rem 文件名 设置DNS域名服务器地址BAT批处理脚本文件.batrem 用途 设置"无线网络连接" 的DNS域名服务器地址netsh interface ip add dns "无线网络连接" 8.8.8.8netsh interface ip add dns "无线网络连接" 8.8.4.4netsh interface ip add dns "无线网络连接" 1.2.4.8netsh interface ip add

powershell脚本-DNS

function InstallDNS   {    servermanagercmd -q c:\role.xml|Out-Null    $xml=[xml](Get-Content c:\role.xml)    $dnsrole=$xml.servermanagerconfigurationquery.role|where{$_.id -eq "dns"}    if($dnsrole.Installed -eq $false)      {      servermanage

云服务程序在启动的时候执行Powershell脚本

如果在云服务程序启动时候,需要执行Powershell脚本,我们需要将脚本嵌入到程序中,并且编写一个cmd来执行这个脚本,具体如下: 1.编写测试的Powershell脚本:每隔10分钟 检测dns $TimeStart = Get-Date $TimeEnd = $timeStart.addminutes(1440) $name = "cnppmedia.blob.core.chinacloudapi.cn." $result = "d:\nslookuplog.txt&q

Azure PowerShell (6) 设置Virtual Machine Endpoint

<Windows Azure Platform 系列文章目录> 请注意: - Azure不支持增加Endpoint Range - 最多可以增加Endpoint数量为150 http://azure.microsoft.com/zh-cn/documentation/articles/azure-subscription-service-limits/ 我们可以通过Windows Azure Management Portal,打开Virtual Machine的Endpoint,借用我之前博

PowerShell 脚本执行策略

为防止恶意脚本的执行,PowerShell 中设计了一个叫做执行策略(Execution Policy)的东西(我更倾向于把它叫做脚本执行策略).我们可以在不同的应用场景中设置不同的策略来防止恶意脚本的执行.本文主要是解释这些执行策略,因为笔者在学习的时候发现它们并不是那么清晰易懂.PowerShell 提供了 Restricted.AllSigned.RemoteSigned.Unrestricted.Bypass.Undefined 六种类型的执行策略,接下来我们一一介绍. Restrict

PowerShell脚本授权最佳实践

[TechTarget中国原创] Windows PowerShell已成为微软在Windows Server上提供的首选管理界面.因为深度整合到Windows Server操作系统,PowerShell表面看上去可以不受任何限制做任何事情.然而,实际上能做得并没有那么多. Windows Server最好用的功能之一就是可以运行脚本.PowerShell脚本允许代码重复使用,并支持运行复杂的命令序列,这是其他方式无法实现的. PowerShell脚本的编写者必须关注的一个大问题就是授权.Pow

windows 脚本设置多IP

毫无疑问,在windows中设置IP非常方便,因为有简单直观的界面可供操作.通过图形用户界面设置IP在一般情况下是够用的,但是对于那些经常出差,变换工作产所的人来说,这样修改IP无疑是耗时且不方便的.如果把设置IP的命令放在一个脚本文件中执行,则非常方便迅速. 用命令行设置IP步骤(WIN7,针对IPV4设置): 1.设置一个静态IP netsh interface ipv4 set address name="本地连接" source=static addr=192.168.20.1

WindowsAzure Powershell脚本定时启动关机Azure VM

说到windowsazure对于当下不是一个新鲜话题了,但是对于功能来说还是有点期待的,毕竟在云服务的世界里windowsazure还是一个菜鸟了.同样我们都知道,对于windowsazure上的服务操作我们有很多方式可以操作,比如:portal页面,powershell with azure及azure pack等,其他的都是图形界面操作,操作相对简单,今天咱们就说说通过windows azure powershell命令来管理windows azure上的部分服务,powershell操作命

2. PowerShell -- 脚本执行权限

1. Powershell  脚本运行的几种权限介绍 Restricted--默认的设置, 不允许任何script运行 AllSigned--只能运行经过数字证书签名的script RemoteSigned--运行本地的script不需要数字签名,但是运行从网络上下载的script就必须要有数字签名 Unrestricted--允许所有的script运行,但是在运行前会提示是否进行操作 Bypass: --允许所有的script运行,没有任何的提示和警告,开发者多时候此策略 2.  查看当前Po