为Azure虚拟机添加第二块网卡
来源:互联网 发布:网络改号电话 编辑:程序博客网 时间:2024/05/16 07:15
为Azure虚拟机添加第二块网卡
有时候我们将虚拟机创建好之后发现还需要第二块网卡,使用下面的脚本我们可以轻松的添加第二块网卡到ARM虚拟机。
脚本运行步骤:
1. 弹出登录窗口中输入登录凭据
2.选择要添加网卡的虚拟机
3.选择网卡所在的子网
4.去倒杯水吧......
#------------------------------------------------------------------------------ # User own the risk, otherwise exit.# # Azure PowerShell Version: 3.6.0## Create by Zeno. #------------------------------------------------------------------------------ Login-AzureRmAccount -EnvironmentName AzureChinaCloud -Credential $(Get-Credential -UserName admin@xxx.partner.onmschina.cn -Message Login_AzureChinaCloud) |Out-Null#获取虚拟机信息$vm = Get-AzureRmVM | Select-Object Name,ResourceGroupName,Location,NetworkInterfaceIDs | Out-GridView -PassThru -Title "Select your VM" $rgName = $vm.ResourceGroupName$location = $vm.Location$nic2 = ($vm.Name + "-nic2").ToLower()$Subnet = Get-AzureRmVirtualNetwork | Get-AzureRmVirtualNetworkSubnetConfig | Select-Object Name,Id,AddressPrefix| Out-GridView -PassThru -Title "Select your New NIC's Subnet"#解除分配write-host "`n`tStop the Select VM!" -ForegroundColor Green$stopvm = Stop-AzureRmVM -Name $vm.Name -ResourceGroupName $rgName#添加新的NICwrite-host "`n`tAdd the Second NIC to VM!" -ForegroundColor Green$nic2 = New-AzureRmNetworkInterface -ResourceGroupName $rgName -Name $nic2 -Location $location -SubnetId $Subnet.Id$addnic = Get-AzureRmVM -Name $vm.Name -ResourceGroupName $rgName | Add-AzureRmVMNetworkInterface -Id $nic2.Id -Primary |Update-AzureRmVM#切换主网卡write-host "`n`tChange the Primary NIC!" -ForegroundColor Green$myvm = Get-AzureRmVM -Name $vm.Name -ResourceGroupName $rgName$myvm.NetworkProfile.NetworkInterfaces[0].Primary = $true$myvm.NetworkProfile.NetworkInterfaces[1].Primary = $false$changenic = Update-AzureRmVM -VM $myvm -ResourceGroupName $rgName#启动虚拟机write-host "`n`tStart the VM!" -ForegroundColor Green$startvm = Get-AzureRmVM -Name $vm.Name -ResourceGroupName $rgName | Start-AzureRmVM
阅读全文
0 0
- 为Azure虚拟机添加第二块网卡
- 为CentOS虚拟机添加第二块网卡
- 为openfiler添加第二块网卡
- VirtualBox下为Ubuntu虚机添加第二块网卡
- 为虚拟机添加一张网卡
- 为linux虚拟机增加第二块硬盘
- edhat/Centos第二块网卡添加/绑定IP
- 安装第二块网卡
- 在虚拟机vmware中为solaris添加网卡备记
- 虚拟机添加网卡
- Xen虚拟机添加网卡
- openstack 虚拟机添加网卡
- 虚拟机centos系统,停机装第二块网卡,需要更改的配置
- 为你的虚拟机添加第二个硬盘!
- 为你的虚拟机添加第二个硬盘!
- [Azure]使用Powershell批量添加虚拟机ACL
- 虚拟机 ubuntu里添加第二块硬盘之实例与分析
- 如何为Azure虚拟机附加磁盘
- 056、057、058-C++
- [RK3288][Android6.0] 调试笔记 --- Audio的Voice Call无法静音问题
- VC++ 取得 其他app的ListBox 内容
- 华为实习day4
- php上下文(Context)介绍
- 为Azure虚拟机添加第二块网卡
- Font Helvetica, Times-Roman is not embedded
- Android 音频数据传输流程图
- Unsupervised Learning of Video Representations using LSTMs
- Selenium设置等待时间的几种方法
- Android 新框架 -- kotlin
- Zookeeper,你可把我坑惨了!
- OpenCV学习笔记(22)寻找轮廓小程序
- OkHttp基本使用