Advertisement
mharrison0224

Untitled

Jun 28th, 2016
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. Import-AzureRM
  2.  
  3. $cred = Get-Credential
  4. $psCred = New-Object System.Management.Automation.PSCredential($cred.UserName, $cred.Password)
  5.  
  6. Login-AzureRmAccount -Credential $psCred -SubscriptionID -TenantId
  7.  
  8. $CompanyPrefix = Read-Host 'Please type in the Prefix you would like all resorces to be named with'
  9. $AzureRGName = Read-Host 'Please type in the resource group name used for this operation, this script will create a resource group with that name if one is not available'
  10. $AzureRMResourceGroupName = Get-AzureRMResourceGroup -Name $AzureRGName
  11.  
  12. if ($AzureRMResourceGroupName -eq $null)
  13. {
  14. $AzureRMLocation = Read-Host 'Please Enter a Location for the Resource Group'
  15. New-AzureRMResourceGroup -Name $AzureRGName -Location $AzureRMLocation
  16. Write-Output 'Could not find Specified Resource Group, One has now been created'
  17. $AzureRMResourceGroupName = Get-AzureRMResourceGroup -Name $AzureRGName
  18. }
  19.  
  20. if (!($AzureRMResourceGroupName.ProvisioningState -eq 'Succeeded')) {
  21. do {
  22. Write-host "Waiting for" $AzureRMResourceGroupName " to have a 'Succeeded' status ...."
  23. Start-Sleep -s 5 #Wait 5 seconds
  24. #Check the power status
  25. $AzureRMResourceGroupName = Get-AzureRMResourceGroup -Name $AzureRGName
  26. $rsgStatus = $AzureRMResourceGroupName.ProvisioningState
  27. }until($rsgStatus -eq "Succeeded")
  28. }
  29.  
  30. $VnetName = $CompanyPrefix + '-Vnet'
  31.  
  32. #$subnet1 = New-AzureRmVirtualNetworkSubnetConfig -Name 'Gateway Subnet' -AddressPrefix '10.10.1.0/28'
  33. #$subnet2 = New-AzureRmVirtualNetworkSubnetConfig -Name 'Default' -AddressPrefix '10.10.0.0/24'
  34. New-AzureRmVirtualNetwork -Name $VnetName -ResourceGroupName $AzureRMResourceGroupName.ResourceGroupName -Location $AzureRMResourceGroupName.Location -AddressPrefix '10.10.0.0/16'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement