Skip to content

Instantly share code, notes, and snippets.

@morgansimonsen
Created December 19, 2013 13:58
Show Gist options
  • Save morgansimonsen/8039470 to your computer and use it in GitHub Desktop.
Save morgansimonsen/8039470 to your computer and use it in GitHub Desktop.
Count all CPU cores for subscription across all cloud services
# 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