Loading

Create VM using Powershell in Azure

To Create VM’s in azure using Powershell you first need to Create an SSL Certificate, Download profile Details, and Install the Powershell Cm-Lets.

Create SSL : http://msdn.microsoft.com/en-us/library/windowsazure/gg551722.aspx
Create Profile and Download Powershell Cm-lets: http://msdn.microsoft.com/en-us/library/windowsazure/jj554332.aspx

The following script can then be executed from Powershell


Set-ExecutionPolicy RemoteSigned
# generate login details https://windows.azure.com/download/publishprofile.aspx Import-AzurePublishSettingsFile C:VMMY.publishsettings
$MySubName = 'Production' Set-AzureSubscription -SubscriptionName $mySubName -CurrentStorageAccount "" # Get-AzureAffinityGroup $wag = ''
#Deploy a new VM and join it to the domain

#-------------------------------------------
$clientName = 'ICS-WIN8-094'

$image = 'Windows8Ent'
$service = $clientName
$vnet = 'azure'
$pwd = '<password>'
$size = 'Small'
#-------------------------------------------------------------------------
$vmname = $clientName $MyVM1 = New-AzureVMConfig -name $vmname -InstanceSize $size -ImageName $image | Add-AzureProvisioningConfig -WindowsDomain -Password $pwd -Domain 'NT' -DomainPassword '<password>' -DomainUserName '<username>' -JoinDomain '<domain>'| Set-AzureSubnet -SubnetNames '<subnetname>'
New-AzureVM -ServiceName $service -VMs $MyVM1 -VNetName $vnet -AffinityGroup $wag

Leave a Reply

Your email address will not be published. Required fields are marked *