-
#The virtual machines for each subscription
-
#The subscription Number.
-
$AAID = 60..70
-
#The Subscription'ID prefix
-
$MS = "MS-"
-
foreach ( $n in $AAID )
-
{
-
$ID = $MS+$n
-
Select-AzureSubscription -SubscriptionName $ID
-
Get-AzureVM
-
}
-
-
-
#batch remove the subscriptionnames name
-
$ID = Get-AzureSubscription|select SubscriptionName
-
$ID | Remove-AzureSubscription
-
-
#batch shutdown VM
-
$MSID="Enterprise-30核-10-2","MS-11","Enter-xiaomi"
-
#$Vname=(100..110)
-
#$Svname="ftest"
-
foreach ( $ID in $MSID ) {
-
#$SV=$Svname+$n
-
Select-AzureSubscription -SubscriptionName $ID
-
Get-AzureVM|Stop-AzureVM -StayProvisioned #(The StayProvisioned has VIP when vm was shutdowned.it will be costed)
-
}
-
-
#check the virtual machines status in diffierent subscriptions
-
$MSID="Enterprise-30核-10-2"
-
#$Vname=(100..110)
-
#$Svname="ftest"
-
foreach ( $ID in $MSID ) {
-
#$SV=$Svname+$n
-
Select-AzureSubscription -SubscriptionName $ID
-
Get-AzureVM
-
}
#batch delete, reboot, shutdown, down remote RDP files
-
#The subscription ID name
-
$AAID = "name"
-
#save the file name suffix
-
$RDP = ".rdp"
-
#the subscription id name prefix
-
$MS = "MS-"
-
-
#Location fo the remote file storages
-
$DISK = "f:\test\"
-
foreach ( $n in $AAID ) {
-
$ID = $MS+$n
-
-
Select-AzureSubscription -SubscriptionName $ID
-
foreach ( $v in (0,1) ) {
-
$VM = Get-AzureVM
-
$Vname = $VM[$v].Name
-
$Sname = $VM[$v].ServiceName
-
$DDISK = $DISK+$Vname+$RDP
-
#write-host $v
-
#write-host $Vname
-
#write-host $Sname
-
# write-host $DDISK
-
###Please manually, annotation modify the content information, and make the corresponding operation
-
-
#Write-Host "check the subscription' virtual machines,Please wait for a minutes...."
-
#Write-Host $ID
-
#Get-AzureVM
-
-
#Write-Host "remove the virtual machine, Please wait for a minites..."
-
#Remove-AzureVM -ServiceName $Sname -Name $Vname -Verbose
-
-
#Write-Host "remove the cloud server, Please wait for a minites..."
-
#Remove-AzureService -ServiceName $Sname -Force
-
-
#Write-Host "Remove all VHD, Please wait....."
-
#Get-AzureDisk|select DiskName|Remove-AzureDisk -DeleteVHD
-
-
-
#Write-Host "Reboot the virtual machine, Please wait for a minutes..."
-
#Restart-AzureVM -ServiceName $Sname -Name $Vname
-
-
#Write-Host "Shutdown the virtual machine, Plase wait for a minutes..."
-
#Stop-AzureVM -ServiceName $Sname -Name $Vname -StayProvisioned #(The StayProvisioned,the VIP,internet IP will be save when the virtual machines shutdown)
-
-
#Write-Host "Down the"$ID" RDP files, Please wait for a minutes..."
-
#Get-AzureRemoteDesktopFile -ServiceName $Sname -Name $Vname -LocalPath $DDISK
-
}
-
}
-
-
-
-
##batch down remote RDP files
-
-
#The subscription ID name.
-
$AAID = 100..108
-
#save file sufix
-
$RDP = ".rdp"
-
#The subscription prefix
-
$MS = "MS-"
-
-
#Location of the remote files
-
$DISK = "f:\test\"
-
foreach ( $n in $AAID ) {
-
$ID = $MS+$n
-
-
Select-AzureSubscription -SubscriptionName $ID
-
foreach ( $v in (0,1) ) {
-
$VM = Get-AzureVM
-
$Vname = $VM[$v].Name
-
$Sname = $VM[$v].ServiceName
-
$DDISK = $DISK+$Vname+$RDP
-
#write-host $v
-
# write-host $Vname
-
#write-host $Sname
-
# write-host $DDISK
-
-
# $ID
-
# Get-AzureVM
-
Get-AzureRemoteDesktopFile -ServiceName $Sname -Name $Vname -LocalPath $DDISK
-
-
}
-
}
-
-
-
##check the virtual machines(Port,DNS,URL etc..)
-
-
#the subscription id name
-
$AAID = "name"
-
#the subscription id prefix
-
$MS = ""
-
-
foreach ( $n in $AAID ) {
-
$ID = $MS+$n
-
Select-AzureSubscription -SubscriptionName $n
-
#Write-Host "check"$ID" the subscription' virtual machines status"
-
#Get-AzureVM |Get-AzureDeployment |select "Name","Url","Status"
-
Write-Host "check"$ID" the subscription' virtual machines' IP ,VIP, Port etc..."
-
Get-AzureVM |Get-AzureEndpoint |select "Name","Vip","Protocol","Port"
-
-
}
-
-
-
###import the subscription
-
Get-AzurePublishSettingsFile -Environment AzureChinaCloud
-
Import-AzurePublishSettingsFile Publish_name(the subscription name)
-
-
###check the subscription names
-
Get-AzureSubscription|select SubscriptionName
-
-
######batch create virtual machines in the diffieretion subscription
-
$MSID = 60..65 #the subscription sufix
-
$VMNUM = 82..93 #the virtual machines sufix
-
$MS = "MS-" #the subscription prefix
-
$STORAGE = "portalwkgbcwfjkdsf" #the storage accout prefix
-
$location = "China North" #location
-
$VMSIZE = "Small" #create virtual machine size(ExtaSmall(V0),Small(V1),Medium(V2),Large(V3),)
-
$VNAME = "ftest0" #create virtual machine prefix
-
$a=0
-
foreach ( $n in $MSID ) {
-
$ID = $MS+$n
-
#$SNAME = $VNAME+$m
-
#$NSTORAGE = $STORAGE+$SNAME
-
$b=$a*2;
-
$c=$a*2+1;
-
$STORAGE = $VNAME+$VMNUM[$b]
-
-
$Vnm1 = $VMNUM[$b]
-
$Vnm2 = $VMNUM[$c]
-
-
# Write-Host $ID
-
# Write-Host $Vnm1
-
# Write-Host $Vnm2
-
Select-AzureSubscription -SubscriptionName $ID
-
New-AzureStorageAccount -StorageAccountName $STORAGE -Location $location
-
-
#batch create Linux virtual machines
-
#<
-
#$imageName = "f1179221e23b4dbb89e39d70e5bc9e72__OpenLogic-CentOS-65-20140415" #Linux image files
-
#$Vnm1..$Vnm2|ForEach {New-AzureVMConfig -Name $VNAME$_ -InstanceSize $VMSIZE -ImageName $imageName ` |
-
#Add-AzureProvisioningConfig -Linux LinuxUser ‘testadmin’ -Password 'Passw0rd' ` |
-
#Add-AzureEndpoint -Name "Http" -Protocol "tcp" -PublicPort 80 -LocalPort 80 |
-
#Add-AzureEndpoint -Name "Http" -Protocol "tcp" -PublicPort 21 -LocalPort 21 |
-
#New-AzureVM -ServiceName $VNAME$_ -Location 'China North'}
-
#$a++
-
#>
-
-
#batch create Widows virtual machines
-
$imageName = "55bc2b193643443bb879a78bda516fc8__Win2K8R2SP1-Datacenter-201403.01-zh.cn-127GB.vhd" #Windows image files
-
$Vnm1..$Vnm2|ForEach {
-
New-AzureVMConfig -Name $VNAME$_ -InstanceSize $VMSIZE -ImageName $imageName ` |
-
Add-AzureProvisioningConfig -Windows -AdminUsername ‘testadmin’ -Password 'Passw0rd' ` |
-
Add-AzureEndpoint -Name "Http" -Protocol "tcp" -PublicPort 80 -LocalPort 80 |
-
Add-AzureEndpoint -Name "Http" -Protocol "tcp" -PublicPort 21 -LocalPort 21 |
-
New-AzureVM -ServiceName $VNAME$_ -Location 'China North'
-
}
-
-
$a++
-
-
}
-
-
-
-
#batch create virtual machines, it's tested
-
-
#the subscription id name
-
$ID = "MS-85"
-
#the storage account name
-
$STORAGE = "portalftest148"
-
#location
-
$location = "China North"
-
#Switch the subscription id
-
Select-AzureSubscription -SubscriptionName $ID
-
#create storage account
-
New-AzureStorageAccount -StorageAccountName $STORAGE -Location $location
-
#set storage account default
-
Set-AzureSubscription -SubscriptionName $ID -CurrentStorageAccountName $STORAGE
-
#set windows 08 images
-
$imageName = "55bc2b193643443bb879a78bda516fc8__Win2K8R2SP1-Datacenter-201403.01-zh.cn-127GB.vhd"
-
#create virtual machines
-
147..148|ForEach {New-AzureVMConfig -Name ftest$_ -InstanceSize 'Small' -ImageName $imageName ` |
-
Add-AzureProvisioningConfig –Windows –AdminUsername ‘testadmin’ -Password 'Passw0rd' ` |
-
Add-AzureEndpoint -Name "Http" -Protocol "tcp" -PublicPort 80 -LocalPort 80 |
-
New-AzureVM -ServiceName ftest$_ -Location 'China North'}
-