Azure虚拟机批量设置静态IP
来源:互联网 发布:php正则表达式 编辑:程序博客网 时间:2024/06/05 21:12
我们平常在Azure部署多台虚拟机之后,可能希望虚拟机的IP就此固定,不要发生由于批量停、开机导致PIP变化的情况,使用下面的PowerShell脚本,我们可以很方便的将虚拟机PIP批量设置为静态。
先上个运行结果图:
以下为脚本内容:
#------------------------------------------------------------------------------ # User own the risk, otherwise exit.# # Azure PowerShell Version: 3.6.0## Create by Zeno. #------------------------------------------------------------------------------ #Login AzureChinaCloud#Login-AzureRmAccount -EnvironmentName AzureChinaCloud -Credential $(Get-Credential -UserName admin@xxx.partner.onmschina.cn -Message Login_AzureChinaCloud) |Out-Null$nics = Get-AzureRmNetworkInterface #-ResourceGroupName $nicrg -Name $nicnameforeach($nic in $nics){$nic.IpConfigurations[0].PrivateIpAllocationMethod = "Static"#$nic.IpConfigurations[1].PrivateIpAllocationMethod = "Dynamic"Set-AzureRmNetworkInterface -NetworkInterface $nic -ErrorAction Stop | Out-NullWrite-Host ("Private NetworkInterface {0}'s IpAddress is Allocated to {1} Successful" -f $nic.Name, $nic.IpConfigurations.PrivateIpAddress) -ForegroundColor Green}#显示所有虚拟网卡信息Write-Host "`n`tDisplay all NICs current status:" -ForegroundColor GreenGet-AzureRmNetworkInterface |Get-AzureRmNetworkInterfaceIpConfig |` Format-Table @{Name="NIC"; Expression={$_.Id.split('/')[-3]}},PrivateIpAllocationMethod,PrivateIpAddress,` @{Name="Subnet"; Expression={$_.Subnet.Id.split('/')[-1]}},` @{Name="AllcatedPIP"; Expression={$_.PublicIpAddress.Id.split('/')[-1]}}
阅读全文
0 0
- Azure虚拟机批量设置静态IP
- Azure虚拟机设置静态IP
- 虚拟机静态ip设置
- VMware虚拟机静态IP设置
- CentOS虚拟机设置静态ip
- 虚拟机 ubuntu设置静态IP
- Linux虚拟机设置静态IP
- 设置虚拟机静态上网ip
- 虚拟机Nat静态IP设置
- 虚拟机的静态ip设置
- ubuntu11.04 虚拟机静态ip设置
- ubuntu11.04 虚拟机静态ip设置
- 虚拟机中设置ubuntu为静态ip
- 虚拟机下ubuntu静态ip设置
- Ubuntu 虚拟机设置静态IP地址
- centos虚拟机NAT静态IP设置
- 虚拟机中ubuntu设置静态IP
- 虚拟机上设置静态IP的做法。
- 数据库无法连接
- 鉴于团队需要java和.net 的融合,在网上找到JNBridgePro这个插件
- 安卓基础4:网络编程1_消息机制和图片处理
- FormsAuthentication.SignOut() 后,并未真正退出的原因
- #!_MVC数据库连接访问与生成问题
- Azure虚拟机批量设置静态IP
- 已有打开的与此 Command 相关联的 DataReader,必须首先将它关闭
- mysql——数据库事务(C#代码)
- MVC开发Entity更新数据库错误
- asp.net Mvc 访问静态页面
- codeforces An express train to reveries 814B
- 【转】C#中调用python脚本
- 重装powershell出现错误
- Android 仿微博@ # 艾特 话题功能