Skip to content

Commit

Permalink
Merge pull request #4 from diecknet/fixAbortIfRGnotfound
Browse files Browse the repository at this point in the history
  • Loading branch information
diecknet authored Sep 21, 2023
2 parents 9db21e9 + a76e1e8 commit a1c301f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions SimpleAzureVMStartStop.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
- Microsoft.Compute/virtualMachines/read
.NOTES
Version: 1.2.1
Version: 1.2.2
Author: Andreas Dieckmann
Creation Date: 2023-09-21
GitHub: https://github.com/diecknet/Simple-Azure-VM-Start-Stop
Expand Down Expand Up @@ -123,7 +123,7 @@ if ([string]::IsNullOrEmpty($AzContext.Subscription)) {
if ($VMName -eq "*") {
try {
# if "*" was given as the VMName, get all VMs in the resource group
$VMs = Get-AzVM -ResourceGroupName $ResourceGroupName
$VMs = Get-AzVM -ResourceGroupName $ResourceGroupName -ErrorAction Stop
}
catch {
$ErrorMessage = "Error getting VMs from resource group ($ResourceGroupName): " + $_.Exception.message
Expand All @@ -137,7 +137,7 @@ if ($VMName -eq "*") {
else {
try {
# get only the specified VM
$VMs = Get-AzVM -ResourceGroupName $ResourceGroupName -VMName $VMName
$VMs = Get-AzVM -ResourceGroupName $ResourceGroupName -VMName $VMName -ErrorAction Stop
}
catch {
$ErrorMessage = "Error getting VM ($VMName) from resource group ($ResourceGroupName): " + $_.Exception.message
Expand Down

0 comments on commit a1c301f

Please sign in to comment.