e82*_*ric 2 powershell powershell-2.0
当我尝试在以管理员身份运行的 Windows 7 上使用 Get-Counter cmdlet 时,出现以下错误。
Get-Counter -computername "$env:ComputerName" '\Memory\Available MBytes'
Get-Counter : Unable to connect to the specified computer or the computer is of
fline.
At line:1 char:12
+ Get-Counter <<<< -computername "$env:ComputerName" '\Memory\Available MBytes
'
+ CategoryInfo : InvalidResult: (:) [Get-Counter], Exception
+ FullyQualifiedErrorId : CounterApiError,Microsoft.PowerShell.Commands.Ge
tCounterCommand
Run Code Online (Sandbox Code Playgroud)
当我在 XP 64 和 Windows 7 上按原样尝试它时,同样的命令可以工作,当我排除 -computername 参数时。
关于如何使用 computername 参数使其在 Windows 7 上工作的任何想法?
谢谢
您可以省略 -computername 参数并直接路径计数器:
get-counter "\\$env:computername\Memory\Available MBytes"
Run Code Online (Sandbox Code Playgroud)
这似乎有效。
| 归档时间: |
|
| 查看次数: |
6361 次 |
| 最近记录: |