Created
December 19, 2013 13:58
-
-
Save morgansimonsen/8039470 to your computer and use it in GitHub Desktop.
Count all CPU cores for subscription across all cloud services
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# CountWACores.ps1 | |
# Morgan Simonsen, www.cloudpower.no | |
# Count all CPU cores for subscription across all cloud services | |
$colVMs = @() | |
[int]$TotalCores = 0 | |
$VMs = (Get-AzureService).servicename | foreach {Get-AzureVM -ServiceName $_ } | |
foreach ( $VM in $VMs ) | |
{ | |
$Instance = New-Object System.Object | |
$Instance | Add-Member -type NoteProperty -name "VM Name" -value $VM.Name | |
$Instance | Add-Member -type NoteProperty -name "VM Instance Size" -value $VM.InstanceSize | |
Switch ($VM.InstanceSize) | |
{ | |
# Should ever Windows Azure get additional instance sizes, add them here | |
"ExtraSmall" {$VMCores=0} | |
"Small" {$VMCores=1} | |
"Medium" {$VMCores=2} | |
"Large" {$VMCores=4} | |
"ExtraLarge" {$VMCores=8} | |
} | |
$Instance | Add-Member -type NoteProperty -name "VM Cores" -value $VMCores | |
$colVMs += $Instance | |
$TotalCores += $VMCores | |
} | |
$colVMs | Sort-Object "VM Name" | |
Write-Host "Total number of cores:" $TotalCores |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment