使用Power shell如何让活跃用户在网站中获取数量?
我尝试了以下代码但未获得结果
function Get-WebServiceConnections()
{
$results = @{}
$perfmon = new-object System.Diagnostics.PerformanceCounter
$perfmon.CategoryName = "Web Service"
$perfmon.CounterName = "Current Connections"
$cat = new-object System.Diagnostics.PerformanceCounterCategory("Web Service")
$instances = $cat.GetInstanceNames()
foreach ($instance in $instances)
{
$perfmon.InstanceName = $instance
$results.Add($instance, $perfmon.NextValue())
}
write-output $results
}
(参考 - http://poshcode.org/1146)