Windows Server AppFabric缓存服务+ PowerShell + C# [英] Windows Server AppFabric Cache Service +PowerShell + C#
问题描述
我想用我的C#代码缓存服务powershell命令。到目前为止,我一直无法做到。
我使用了这个帖子中的代码
但是当我运行此代码时,我收到此错误
术语"Use-CacheCluster"未被识别为cmdlet,函数,脚本文件或可操作程序的名称。检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试。
我是使用下面的代码
使用
( PowerShell
ps = PowerShell 。创建
())
{
ps.AddCommand(
" Import-Module" ); < font face ="Consolas"size ="2">
ps.AddParameter(
" Name" ,
"DistributedCacheAdministration" );
ps.Invoke();
ps.AddCommand(
" Use-CacheCluster" );
ps.AddParameter(
<温泉n style ="font-family:Consolas;颜色:#a31515; font-size:x-small">" Provider" ,
" xml" );
ps.AddParameter(
" ConnectionString" ,
@" \\\\
b-gjanjua.corp.geosign.com \ localcache" );
var
results = ps.Invoke();
}
请注意:我使用的是AppFabric 6.0
感谢您的帮助
谢谢和问候 - Gagan
Gagan,
嗨。我有一些与此有点不同的代码。你能尝试类似下面的代码并查看它是否有效吗? / p>
首先,这些是我为缓存和PowerShell调用引用的程序集:
- Microsoft.ApplicationServer.Caching.Client
- Microsoft.ApplicationServer.Caching.Core
- Microsoft.ApplicationServer.Caching.Management(对于下面的HostInfo类)
- System.Management.Automation (对于PowerShell)
然后我使用PowerShell和缓存的以下语句:
使用 System.Management.Automation.Runspaces;
使用 System.Collections.ObjectModel;
使用 System.Management.Automation;
使用 Microsoft.ApplicationServer.Caching;
使用 Microsoft.ApplicationServer.Caching.AdminApi;
Hi,
I would like to use, cache service powershell commands from my C# code. which till now I have not been able to do .
I used code from this thread
http://social.msdn.microsoft.com/Forums/en-US/velocity/thread/60070ba9-fbd8-4672-95b5-91cbcf4305aa
but when i run this code, I am getting this error
The term 'Use-CacheCluster' is not recognized as the name of a cmdlet, function, 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.
I am using the code below
using (PowerShell ps = PowerShell.Create ())
{
ps.AddCommand (
"Import-Module");
ps.AddParameter(
"Name", "DistributedCacheAdministration");
ps.Invoke ();
ps.AddCommand(
"Use-CacheCluster");
ps.AddParameter (
"Provider", "xml");
ps.AddParameter (
"ConnectionString", @"\\nb-gjanjua.corp.geosign.com\localcache");
var results = ps.Invoke ();
}
Please note : I am using AppFabric 6.0
Thanks for the help
Thanks and Regards - Gagan解决方案Gagan,
Hi. I have some code that is a little different from this. Could you try something like the code below and see if it works?
First, these are the assemblies I referenced for caching and PowerShell calls:
- Microsoft.ApplicationServer.Caching.Client
- Microsoft.ApplicationServer.Caching.Core
- Microsoft.ApplicationServer.Caching.Management (for the HostInfo class below)
- System.Management.Automation (for PowerShell)
Then I had the following using statements for both PowerShell and Caching:
using System.Management.Automation.Runspaces; using System.Collections.ObjectModel; using System.Management.Automation; using Microsoft.ApplicationServer.Caching; using Microsoft.ApplicationServer.Caching.AdminApi;
这篇关于Windows Server AppFabric缓存服务+ PowerShell + C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文