search
Categories
Sponsors
VirtualMetric Hyper-V Monitoring, Hyper-V Reporting
Archive
Blogroll

Badges
MCSE
Community

Cozumpark Bilisim Portali
Getting SCVMM 2012 User Role Quotas and Cloud Usage
Posted in Virtual Machine Manager, Windows Powershell | No Comment | 3,651 views | 26/10/2013 20:18

You can use this script to see how much quota user role has and how much consumes in cloud.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Create Quota Array
$QuotaArray = New-Object System.Collections.ArrayList
 
$UserRoles = Get-SCUserRole
foreach ($UserRole in $UserRoles)
{
	$QuotaArray.Clear();
	Write-Host " "
	Write-Host "User Role: $UserRole"
	Write-Host " "
	$Quotas = Get-SCUserRoleQuota | Where RoleID -eq $UserRole.ID
	foreach ($Quota in $Quotas)
	{
		$QuotaCloudID = $Quota.CloudID
		# Get Cloud
		$Cloud = Get-SCCloud | Where ID -eq $QuotaCloudID
		$CloudName = $Cloud.Name
		$CPUCountQuota = $Quota.CPUCount
		$MemoryMBQuota = $Quota.MemoryMB
 
		if ($QuotaArray.Contains("$CloudName") -eq $False)
		{
			# Get Cloud Usage
			$CloudUsage = Get-SCCloudUsage -Cloud $Cloud -UserRole $UserRole
 
			$CPUCountUsage = $CloudUsage.CPUUsageCount
			$MemoryUsageMB = $CloudUsage.MemoryUsageMB
			$StorageUsageGB = $CloudUsage.StorageUsageGB
			$VMUsageCount = $CloudUsage.VMUsageCount
 
			Write-Host "Cloud: $CloudName"
			Write-Host "CPU Count: $CPUCountQuota"
			Write-Host "CPU Count Usage: $CPUCountUsage"
			Write-Host "Memory: $MemoryMBQuota"
			Write-Host "Memory Usage: $MemoryUsageMB"
			Write-Host "Storage Usage: $StorageUsageGB"
			Write-Host "VM Count Usage: $VMUsageCount"
			Write-Host " "
 
			# Add to Array
			$AddArray = $QuotaArray.Add("$CloudName")
		}
	}
}

I tried to do best formating in this :) Output is even more readable now.



Leave a Reply