Skip to content

Commit

Permalink
Merge pull request #92 from smoonlee/3.1.18.2-prod
Browse files Browse the repository at this point in the history
Executing Release Build
  • Loading branch information
smoonlee authored Aug 14, 2024
2 parents 70e1b86 + 22b3022 commit 4d49d2b
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions Microsoft.PowerShell_profile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@ Version: 3.1.16.5 - August 2024 | Verbose Formatting for Change Log
Version: 3.1.16.6 - August 2024 | Verbose Formatting for Change Log
Version: 3.1.17 - August 2024 | GitHub Action Bump - No change made to profile
Version: 3.1.18 - August 2024 | Created Get-AzVMQuotaCheck
version: 3.1.18.1 - August 2024 | Code Tidy and Get-AzVMQuotaCheck released
Version: 3.1.18.1 - August 2024 | Code Tidy and Get-AzVMQuotaCheck released
Version: 3.1.18.2 - August 2024 | Updated Get-AzVMQuotaCheck Logic
#>

# Oh My Posh Profile Version
$profileVersion = '3.1.18.1-prod'
$profileVersion = '3.1.18.2-prod'

# GitHub Repository Details
$gitRepositoryUrl = "https://api.github.com/repos/smoonlee/oh-my-posh-profile/releases"
Expand Down Expand Up @@ -796,7 +797,7 @@ function Get-AzVMQuotaCheck {
"Standard_NV8as_v4", "Standard_NV16as_v4", "Standard_NV32as_v4", "Standard_NV48as_v4", "Standard_NV56as_v4",
"Standard_NV72as_v4"
)]
[string]$SkuType,
[string]$skuType,

[Parameter(Mandatory = $false, Position = 3, HelpMessage = "Enter the subscription ID")]
[string]$subscriptionId
Expand All @@ -805,11 +806,13 @@ function Get-AzVMQuotaCheck {
if ($subscriptionId) {

# List all subscriptions
$subscriptions = az account list --all --output json | ConvertFrom-Json
$subscriptions = az account list --output json --only-show-errors | ConvertFrom-Json
$tenantFriendlyName = az account show --query 'tenantDisplayName' -o tsv

# Check if the provided subscriptionId exists in the list of subscriptions
if ($subscriptions | Where-Object { $_.id -eq $subscriptionId }) {
$subscriptionExists = $true
az account set --subscription $subscriptionId
}

if (!$subscriptionExists) {
Expand All @@ -835,17 +838,19 @@ function Get-AzVMQuotaCheck {
}
}

Write-Output "Checking quota for VM Family '$SkuType' in '$location'"
$subscriptionId = az account show --query 'id' -o tsv
$subscriptionFriendlyName = az account show --query 'name' -o tsv
Write-Output "Checking quota for VM Family '$skuType' in '$location' for subscription: $subscriptionId - $subscriptionFriendlyName"
Write-Warning "This can take 2 minutes to check and report back!!"

# Get the list of VM SKUs for the given location
$SKUFamily = az vm list-skus --location $location --query "[?resourceType=='virtualMachines'].{Name:name, Family:family}" | ConvertFrom-Json

# Check if the SkuType is valid in the given location
$familyInfo = $SKUFamily | Where-Object { $_.Name -eq $SkuType }
$familyInfo = $SKUFamily | Where-Object { $_.Name -eq $skuType }

if ($familyInfo) {
Write-Output "VM Family '$SkuType' is available in the location '$location'. Checking quota..."
Write-Output "VM Family '$skuType' is available in the location '$location'. Checking quota..."

# Get the quota information for the VM family
$quotaInfo = az vm list-usage --location $location --query "[?name.value=='$($familyInfo.Family)']" | ConvertFrom-Json
Expand All @@ -856,10 +861,10 @@ function Get-AzVMQuotaCheck {
}
}
else {
Write-Output "Quota information not available for VM Family '$SkuType'"
Write-Output "Quota information not available for VM Family '$skuType'"
}
}
else {
Write-Output "VM Family '$SkuType' is not valid or not available in the location '$location'"
Write-Output "VM Family '$skuType' is not valid or not available in the location '$location'"
}
}

0 comments on commit 4d49d2b

Please sign in to comment.