Azure-使用PowerShell批量创建VM

PS脚本批量创建机器

使用Azure PowerShell批量创建机器

在熟练使用Azure之后,其实不用登录Azure Portal来手动操作费,只需要使用PowerShell登录进行资源管理和资源创建即可,下面我给大家提供一个批量创建机器的脚本,有兴趣的朋友可以参看。

#################################################################################################
#Before useing this script, Please create below three resources manually on Azure Portal first.
#1.One resource group
#2.One virtual network and create one subnet in this resource group
#3.One diag storage account
#4.This script come from@:www.sugoar.com
#################################################################################################

#Log In Azure:
#Login-AzureRmAccount -EnvironmentName AzureChinaCloud | Out-Null

#Set Location(chinanorth/chinanorth2/chinaeast/chinaeast2):
$location = “chinanorth2”

#Set VMs Size:
$vmSize = “Standard_DS3_V2”

#write-host “ntDefault set is create Linux VM, if you want to create Windows VM,pleare input “n” to exit and reset osDiskSize, Continue to create please input “y”” -ForegroundColor Yellow
#KaTeX parse error: Expected 'EOF', got '#' at position 51: …r Exit? (y/n)" #̲if(input -eq “n”){Exit}
#If Create Linux VM please use this OS Disk Size
#$osDiskSzie = ‘30’

#If Create Windows VM please use this OS Disk Size
$osDiskSzie = ‘127’

#Get the Resource Group created for those VMs:
$ResourceGroup = Get-AzureRmResourceGroup | Select ResourceGroupName,Location | Out-GridView -PassThru -Title “Select your ResourceGroup”

#Get the diageStorage Account created for those VMs:
write-host “ntPleare select the diag storage account for those VMs” -ForegroundColor Green
$StorageAccount = (Get-AzureRmStorageAccount | Select StorageAccountName,ResourceGroupName,Location | Out-GridView -PassThru -Title “Select your diag Storage Account”).StorageAccountName

#Get the Virtual Network and Subnet created for those VMs:
$Subnet = Get-AzureRmVirtualNetwork | Get-AzureRmVirtualNetworkSubnetConfig | Select Name,Id,AddressPrefix| Out-GridView -PassThru -Title “Select your Subnet”

#Set VM name prefix:
$vmNames = “”

#User name and Password for VMs:
$user=""
$pwd=ConvertTo-SecureString “” -AsPlainText -Force
$ c r e d = N e w − O b j e c t S y s t e m . M a n a g e m e n t . A u t o m a t i o n . P S C r e d

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值