$TimePeriod = 30;
$ResourceGroupName = 'ResourceGroupName';
$HostPoolName = 'HostPoolName';
#-------------------------------
$EndTime = Get-Date;
$StartTime = $EndTime.addminutes(-$TimePeriod)
Get-AzWvdUserSession -ResourceGroupName $ResourceGroupName -HostPoolName $HostPoolName | select UserPrincipalName,ActiveDirectoryUserName,ApplicationType,Name,SessionState
$HostPool = $(Get-AzWvdSessionHost -ResourceGroupName $ResourceGroupName -HostPoolName $HostPoolName);
ForEach ($HostName in $HostPool) {
$CPUUtilizationSum = 0;
$HostCPUUtilization = Get-AzMetric -ResourceId $HostName.ResourceId -MetricNames "Percentage CPU" -TimeGrain 00:01:00 -DetailedOutput -StartTime $StartTime -EndTime $EndTime; $HostCPUUtilization.Data.Average.ForEach({$CPUUtilizationSum += [int]$_;}); $CPUUtilizationAverage = ($CPUUtilizationSum / $HostCPUUtilization.Data.Average.Length) write-host ('' + $HostName.Name + "`t" + $CPUUtilizationAverage);
};
沒有留言:
張貼留言