SQL"日志字节脸也红/秒"从PowerShell的错误计数器 [英] SQL "Log Bytes Flushed/sec" counter from powershell Error
问题描述
我想我计算需要用到这个AZURE SQL类型: http://dtucalculator.azurewebsites.net/ => http://dtucalculator.azurewebsites.net/Downloads/sql-perfmon .ZIP
I am trying to calculate the type of AZURE SQL I need using this: http://dtucalculator.azurewebsites.net/ => http://dtucalculator.azurewebsites.net/Downloads/sql-perfmon.zip
这是一个PowerShell脚本,从SQL某些计数器中获取数据,但访问日志字节脸也红/秒时,出现了错误计数器,它是在SQL pressent当我运行
This is a PowerShell script that gets data from some counters from SQL but it errors out when accessing the "Log Bytes Flushed/sec" counter that it is pressent in SQL when I run
select * FROM sys.dm_os_performance_counters where counter_name like 'Log Bytes Flushed/sec%'
我从PowerShell中得到的错误是:
the error I get from PowerShell is:
获取柜台:指定的对象没有在计算机上找到。在
C:\\用户\\ ringhel \\桌面\\ SQL-perfmon.ps1:47字符:1
+获取柜台-Counter $专柜-SampleInterval 1 -MaxSamples 3600 |
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
+ CategoryInfo:InvalidResult:(:) [获取-计数器],异常
+ FullyQualifiedErrorId:CounterApiError,Microsoft.PowerShell.Commands.GetCounterCommand
Get-Counter : The specified object was not found on the computer. At C:\users\ringhel\desktop\sql-perfmon.ps1:47 char:1 + Get-Counter -Counter $counters -SampleInterval 1 -MaxSamples 3600 | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidResult: (:) [Get-Counter], Exception + FullyQualifiedErrorId : CounterApiError,Microsoft.PowerShell.Commands.GetCounterCommand
这个错误来自这个变量:
The error comes from this variable:
$计数器= @(\\处理器(_Total)\\%处理器时间,
\\逻辑磁盘(C:)\\磁盘读取/秒,\\逻辑磁盘(C:)\\磁盘写入/秒
$counters = @("\Processor(_Total)\% Processor Time", "\LogicalDisk(C:)\Disk Reads/sec", "\LogicalDisk(C:)\Disk Writes/sec",
\\逻辑磁盘(C:)\\磁盘读取字节数/秒,\\逻辑磁盘(C:)\\磁盘写入字节数/秒,\\ SQLSERVER:数据库($数据库名)\\登录
鼠国的字节数/秒)
"\LogicalDisk(C:)\Disk Read Bytes/sec", "\LogicalDisk(C:)\Disk Write Bytes/sec", "\SQLSERVER:Databases($DatabaseName)\Log Bytes Flushed/sec")
在网上搜索后,而不是SQLSERVER我试过MSSQLSERVER(这是SQL Server实例的名称),MSSQL'$ MSSQLServer和MSSQL $ MSSQLSERVER但同样的错误。
After searching the web, instead of SQLSERVER I tried MSSQLSERVER (this is the instance name of the SQL server), MSSQL'$MSSQLSERVER and MSSQL$MSSQLSERVER but the same error.
请帮忙。
推荐答案
中发现的问题。
我不得不执行策略设置为LOCALMACHINE为RemoteSigned。它是不确定的。
found the problem. I had to set the execution policy for the LocalMachine to RemoteSigned. It was Undefined.
设置ExecutionPolicy RemoteSigned就是-Scope LOCALMACHINE
Set-ExecutionPolicy RemoteSigned -Scope LocalMachine
这篇关于SQL"日志字节脸也红/秒"从PowerShell的错误计数器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!