Solved

Error Executing Powershell Command in Azure

Posted on 2016-10-22
29
34 Views
Last Modified: 2016-10-22
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
Comment
Question by:Member_2_7966113
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 16
  • 13
29 Comments
 
LVL 7

Expert Comment

by:No More
ID: 41855166
Where is the image ?
0
 
LVL 1

Author Comment

by:Member_2_7966113
ID: 41855175
Oops!

Please see image below

subnet
0
 
LVL 1

Author Comment

by:Member_2_7966113
ID: 41855178
Sorry, that is a bad snapshot

See image below:

image
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:Member_2_7966113
ID: 41855180
Any thoughts?
0
 
LVL 1

Author Comment

by:Member_2_7966113
ID: 41855185
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
 
LVL 7

Expert Comment

by:No More
ID: 41855188
Value in  $gwsubnet   is empty or not set
0
 
LVL 7

Expert Comment

by:No More
ID: 41855192
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
 
LVL 7

Expert Comment

by:No More
ID: 41855196
Recheck from start what you have done
0
 
LVL 7

Expert Comment

by:No More
ID: 41855199
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
 
LVL 1

Author Comment

by:Member_2_7966113
ID: 41855219
Hi David,

Thanks for getting back to me.

I don't see how your suggestion could be the root of the problem??
0
 
LVL 1

Author Comment

by:Member_2_7966113
ID: 41855221
I would have thought the problem was with:

$ipconfig = New-AzureRmVirtualNetworkGatewayIpConfig -Name "gwIpConfig" -SubnetId $gwsubnet.Id -PublicIpAddressId $pip.Id
0
 
LVL 1

Author Comment

by:Member_2_7966113
ID: 41855222
I would have thought the problem was with:

$ipconfig = New-AzureRmVirtualNetworkGatewayIpConfig -Name "gwIpConfig" -SubnetId $gwsubnet.Id -PublicIpAddressId $pip.Id
0
 
LVL 1

Author Comment

by:Member_2_7966113
ID: 41855225
I think the problem is with $gwsubnet.Id
0
 
LVL 7

Expert Comment

by:No More
ID: 41855234
0
 
LVL 7

Expert Comment

by:No More
ID: 41855235
Can you confirm that your script was tested by anybody ?
0
 
LVL 1

Author Comment

by:Member_2_7966113
ID: 41855238
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
 
LVL 7

Expert Comment

by:No More
ID: 41855252
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
 
LVL 7

Expert Comment

by:No More
ID: 41855257
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
 
LVL 1

Author Comment

by:Member_2_7966113
ID: 41855260
David

Done that, see attachment
portal.png
0
 
LVL 7

Expert Comment

by:No More
ID: 41855265
$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
 
LVL 1

Author Comment

by:Member_2_7966113
ID: 41855268
The script is from Azure
0
 
LVL 7

Expert Comment

by:No More
ID: 41855273
Link ?
0
 
LVL 1

Author Comment

by:Member_2_7966113
ID: 41855281
oh, sorry. I'm not actually using a script. I'm just following the step-by-step instructions I sent you.
0
 
LVL 7

Expert Comment

by:No More
ID: 41855290
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
 
LVL 1

Author Comment

by:Member_2_7966113
ID: 41855395
Hi David

Sorry for the delayed response. I trying to create a site-to-site vpn.
0
 
LVL 1

Author Comment

by:Member_2_7966113
ID: 41855455
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
 
LVL 7

Accepted Solution

by:
No More earned 500 total points
ID: 41855477
0
 
LVL 1

Author Comment

by:Member_2_7966113
ID: 41855553
David,

This is a fantastic resource.

Thanks so much

Cheers
0
 
LVL 1

Author Closing Comment

by:Member_2_7966113
ID: 41855554
Fantastic answer
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows 10 came with  a lot of built in applications, Some organisations leave them there, some will control them using GPO's. This Article is useful for those who do not want to have any applications in their image (example:me).
During and after that shift to cloud, one area that still poses a struggle for many organizations is what to do with their department file shares.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question