@@ -12,16 +12,11 @@ function Ensure-Login ()
1212 If ($context.Subscription -eq $null )
1313 {
1414 Write-Host " Loging in ..."
15- Try
15+ If ((Login - AzureRmAccount - ErrorAction SilentlyContinue - ErrorVariable Errors) -eq $null )
1616 {
17- Login- AzureRmAccount - ErrorAction Stop | Out-null
17+ Write-Host (" Login failed: {0}" -f $Errors [0 ].Exception.Message) - ForegroundColor Red
18+ Break
1819 }
19- Catch
20- {
21- Write-Host " Login failed: $_ " - ForegroundColor Red
22- Exit
23- }
24-
2520 }
2621 Write-Host " User logedin." - ForegroundColor Green
2722}
@@ -41,7 +36,7 @@ function Select-SubscriptionId {
4136 Catch
4237 {
4338 Write-Host " Subscription selection failed: $_ " - ForegroundColor Red
44- Exit
39+ Break
4540 }
4641 }
4742 Write-Host " Subscription selected." - ForegroundColor Green
@@ -62,7 +57,7 @@ function Load-VirtualNetwork {
6257 else
6358 {
6459 Write-Host " Virtual network not found." - ForegroundColor Red
65- Exit
60+ Break
6661 }
6762}
6863
@@ -83,7 +78,7 @@ function Load-VirtualNetworkSubnet {
8378 else
8479 {
8580 Write-Host " Subnet not found." - ForegroundColor Red
86- Exit
81+ Break
8782 }
8883}
8984
@@ -99,7 +94,7 @@ function Verify-Subnet {
9994 Else
10095 {
10196 Write-Host " Failed Validation - Minimum supported subnet size is /28." - ForegroundColor Red
102- Exit
97+ Break
10398 }
10499 If (
105100 ($subnet.IpConfigurations.Count -eq 0 ) -and
@@ -114,7 +109,7 @@ function Verify-Subnet {
114109 Else
115110 {
116111 Write-Host " Failed Validation - Subnet is already in use." - ForegroundColor Red
117- Exit
112+ Break
118113 }
119114}
120115
0 commit comments