[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 56
  • Last Modified:

Error Executing Powershell Command in Azure

Hell Experts

Can someone please let me know why I get the error message shown in the image when I try to execute the command shown in the image?

Cheers

Carlton
0
Member_2_7966113
Asked:
Member_2_7966113
  • 16
  • 13
1 Solution
 
No MoreCommented:
Where is the image ?
0
 
Member_2_7966113Author Commented:
Oops!

Please see image below

subnet
0
 
Member_2_7966113Author Commented:
Sorry, that is a bad snapshot

See image below:

image
0
Evaluating UTMs? Here's what you need to know!

Evaluating a UTM appliance and vendor can prove to be an overwhelming exercise.  How can you make sure that you're getting the security that your organization needs without breaking the bank? Check out our UTM Buyer's Guide for more information on what you should be looking for!

 
Member_2_7966113Author Commented:
Any thoughts?
0
 
Member_2_7966113Author Commented:
Experts,

The question may be easier to decipher if I explained that the command above with error is part of series of commands. Please see attached. You will notice that the error occurs in Step 15.

See attached.
Fullstep.txt
0
 
No MoreCommented:
Value in  $gwsubnet   is empty or not set
0
 
No MoreCommented:
Login-AzureRMAccount
Set-AzureRmContext –SubscriptionName <Name of your subscription>
New-AzureRMResourceGroup –Name AdatumRG –Location centralus
$vnet = New-AzureRMVirtualNetwork –ResourceGroupName AdatumRG –Name AdatumVnet –AddressPrefix 192.168.0.0/16 –Location centralus
Add-AzureRmVirtualNetworkSubnetConfig -Name AdatumSubnet -VirtualNetwork $vnet -AddressPrefix 192.168.1.0/24
Add-AzureRmVirtualNetworkSubnetConfig -Name GatewaySubnet -VirtualNetwork $vnet -AddressPrefix 192.168.200.0/28
Set-AzureRMVirtualNetwork –VirtualNetwork $vnet
$GW = New-AzureRmLocalNetworkGateway -Name "AdatumLocalGW" -ResourceGroupName "AdatumRG" -Location "centralus" -GatewayIpAddress "111.111.111.111" -AddressPrefix "10.1.0.0/24"
$route = New-AzureRmRouteConfig -Name DefaultRoute `
    -AddressPrefix 0.0.0.0/0 -NextHopType VirtualNetworkGateway
$routeTable = New-AzureRmRouteTable -ResourceGroupName AdatumRG -Location centralus `
    -Name Adatum-FT -Route $route
Set-AzureRmVirtualNetworkSubnetConfig -VirtualNetwork $vnet -Name AdatumSubnet `
    -AddressPrefix 192.168.1.0/24 -RouteTable $routeTable
Set-AzureRMVirtualNetwork –VirtualNetwork $vnet
$pip = New-AzureRmPublicIpAddress -Name "GatewayIP" -ResourceGroupName "AdatumRG" -Location "centralUS" -AllocationMethod Dynamic
$gwsubnet = Get-AzureRmVirtualNetworkSubnetConfig -Name "GatewaySubnet" -VirtualNetwork $vnet
$ipconfig = New-AzureRmVirtualNetworkGatewayIpConfig -Name "gwIpConfig" -SubnetId $gwsubnet.Id -PublicIpAddressId $pip.Id
$Gateway1 = New-AzureRmVirtualNetworkGateway -Name "Gateway1" -ResourceGroupName "AdatumRG" -Location "centralus" -IpConfigurations $ipconfig -GatewayType Vpn -VpnType RouteBased -GatewayDefaultSite $GW -EnableBgp $false
0
 
No MoreCommented:
Recheck from start what you have done
0
 
No MoreCommented:
Possible root of problem:

$vnet = New-AzureRMVirtualNetwork –ResourceGroupName AdatumRG –Name AdatumVnet –AddressPrefix 192.168.0.0/16 –Location centralus

Add-AzureRmVirtualNetworkSubnetConfig -Name GatewaySubnet -VirtualNetwork $vnet -AddressPrefix 192.168.200.0/28
0
 
Member_2_7966113Author Commented:
Hi David,

Thanks for getting back to me.

I don't see how your suggestion could be the root of the problem??
0
 
Member_2_7966113Author Commented:
I would have thought the problem was with:

$ipconfig = New-AzureRmVirtualNetworkGatewayIpConfig -Name "gwIpConfig" -SubnetId $gwsubnet.Id -PublicIpAddressId $pip.Id
0
 
Member_2_7966113Author Commented:
I would have thought the problem was with:

$ipconfig = New-AzureRmVirtualNetworkGatewayIpConfig -Name "gwIpConfig" -SubnetId $gwsubnet.Id -PublicIpAddressId $pip.Id
0
 
Member_2_7966113Author Commented:
I think the problem is with $gwsubnet.Id
0
 
No MoreCommented:
Can you confirm that your script was tested by anybody ?
0
 
Member_2_7966113Author Commented:
Hi David,

The link is the same as my command (except of course for a few syntax)

$subnet = Get-AzureRmVirtualNetworkSubnetConfig -Name 'GatewaySubnet' -VirtualNetwork $vnet

$gwipconfig = New-AzureRmVirtualNetworkGatewayIpConfig -Name gwipconfig1 -SubnetId $subnet.Id -PublicIpAddressId $gwpip.Id

So, I don't understand why my command won't gives me an error with $gwsubnet.Id  ?
0
 
No MoreCommented:
Possibly this.
Still looking around maybe I'm missing something

Yours
Add-AzureRmVirtualNetworkSubnetConfig -Name GatewaySubnet -VirtualNetwork $vnet -AddressPrefix 192.168.200.0/28

Other one
Add-AzureRMVirtualNetworkSubnetConfig -Name GatewaySubnet -AddressPrefix 10.0.3.0/28 -VirtualNetwork $vnet
0
 
No MoreCommented:
Create your network in the portal, make sure to add all address spaces and subnets before running script. Do NOT forget to add “GatewaySubnet”.
0
 
Member_2_7966113Author Commented:
David

Done that, see attachment
portal.png
0
 
No MoreCommented:
$GW = New-AzureRmLocalNetworkGateway -Name "AdatumLocalGW" -ResourceGroupName "AdatumRG" -Location "centralus" -GatewayIpAddress "111.111.111.111" -AddressPrefix "10.1.0.0/24"

111.111.111.111  - Are you sure this is correct


I was setting this before, but In portal. I saw another script, can you tell me source of your script ?
0
 
Member_2_7966113Author Commented:
The script is from Azure
0
 
No MoreCommented:
Link ?
0
 
Member_2_7966113Author Commented:
oh, sorry. I'm not actually using a script. I'm just following the step-by-step instructions I sent you.
0
 
No MoreCommented:
Well then this could be mission impossible

Could you tell me what exact connection type are you creating ?

I might be able to point you to more readable script
0
 
Member_2_7966113Author Commented:
Hi David

Sorry for the delayed response. I trying to create a site-to-site vpn.
0
 
Member_2_7966113Author Commented:
Experts,

I'm now using the following site-to-site script but again I can't get it to connect.

https://github.com/Azure/azure-quickstart-templates/tree/052db5feeba11f85d57f170d8202123511f72044/101-site-to-site-vpn-create
0
 
Member_2_7966113Author Commented:
David,

This is a fantastic resource.

Thanks so much

Cheers
0
 
Member_2_7966113Author Commented:
Fantastic answer
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 16
  • 13
Tackle projects and never again get stuck behind a technical roadblock.
Join Now