1

我正在调用以下简单的 Powershell AppFabric 命令:

powershell -noexit c:\scripts\ApplyClusterConfig.ps1

脚本只包含:

Get-CacheStatistics

我收到以下错误:

The term 'Get-CacheStatistics' is not recognized as the name of a cmdlet, funct
ion, script file, or operable program. Check the spelling of the name, or if a
path was included, verify that the path is correct and try again.
At C:\scripts\ApplyClusterConfig.ps1:1 char:20
+ Get-CacheStatistics <<<<
    + CategoryInfo          : ObjectNotFound: (Get-CacheStatistics:String) [],
    CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

我已经完成了我可以在网上找到的所有内容,包括

Set-ExecutionPolicy Unrestricted

并使用 .\ 来引用文件:

powershell -noexit .\ApplyClusterConfig.ps1

并将环境路径设置为包含 c:\Scripts

但是错误一直存在。任何人都可以帮忙,因为我已经用完了所有谷歌选项。谢谢。

4

1 回答 1

6

正如错误所说,它无法Get-CacheStatistics作为 cmdlet、函数、脚本文件或可运行程序找到。您需要加载必要的模块。

在此处查看有关如何加载必要模块以运行 AppFabric cmdlet 的指导:http: //msdn.microsoft.com/en-us/library/ee677295.aspx

您可能必须添加以下一项或多项导入(可能在您的脚本中):

Import-Module ApplicationServer
Import-Module distributedcacheconfiguration
Import-Module distributedcacheadministration

执行策略与此错误无关,您可以正常运行脚本。

于 2011-09-20T16:03:09.583 回答