$serverName = "DESKTOP-S19MG83\DEVMSSQL"
$Counters = @(
("\$serverName" +"\Process(sqlservr*)\% User Time"),
("\$serverName" +"\Process(sqlservr*)\% Privileged Time")
)
Get-Counter -Counter $Counters -MaxSamples 30 | ForEach {
$.CounterSamples | ForEach {
[pscustomobject]@{
TimeStamp = $.TimeStamp
Path = $.Path
Value = ([Math]::Round($.CookedValue, 3))
}
Start-Sleep -s 2
}
}
After Running this am getting the below error.
Get-Counter : Unable to connect to the specified computer or the computer is offline.
At line:6 char:5
- Get-Counter -Counter $Counters -MaxSamples 30 | ForEach {
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : InvalidResult: (:) [Get-Counter], Exception
- FullyQualifiedErrorId : CounterApiError,Microsoft.PowerShell.Commands.GetCounterCommand
Get-Counter : Unable to connect to the specified computer or the computer is offline.
At line:6 char:5
- Get-Counter -Counter $Counters -MaxSamples 30 | ForEach {
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : InvalidResult: (:) [Get-Counter], Exception
- FullyQualifiedErrorId : CounterApiError,Microsoft.PowerShell.Commands.GetCounterCommand
System is online, firewall is off so what's the issue?