1
我正在使用PowerShell管理單元,我打算將它作爲WSMan模塊的插件託管在IIS上。我想知道如何將其他參數從web.config傳遞給管理單元?如何將參數傳遞給IIS中託管的WinRM插件(PowerShell)
這裏詳細介紹:應用
Web.config文件中的主機PS單元:
<system.webServer>
<system.management.wsmanagement.config>
<PluginModules>
<OperationsPlugins>
<Plugin Name="MyPSPlugin" Filename="%windir%\system32\pwrshplugin.dll" SDKVersion="1" XmlRenderingType="text">
<InitializationParameters>
<!-- I'd like to declare additional parameter for PS span-in here something like this: -->
<Param Name="myData" Value="Test" />
<Param Name="PSVersion" Value="2.0" />
<Param Name="assemblyname" Value="C:\MyServices\PowerShell\Bin\MyPSSnapin.dll" />
<Param Name="pssessionconfigurationtypename" Value="MyCompany.PowerShell.MyPSSessionConfiguration" />
</InitializationParameters>
<Resources>
<Resource ResourceUri="http://schemas.microsoft.com/powershell/Hosting.PowerShell" SupportsOptions="true">
<Capability Type="Shell" />
</Resource>
</Resources>
</Plugin>
</OperationsPlugins>
</PluginModules>
</system.management.wsmanagement.config>
</system.webServer>
這裏實現PSSessionConfiguration的:
namespace MyCompany.PowerShell
{
public class MyPSSessionConfiguration : PSSessionConfiguration
{
public override InitialSessionState GetInitialSessionState(PSSenderInfo senderInfo)
{
// read additional parameter something like this:
var myData = sendrerInfo.ApplicationArguments["myData"];
return base.GetInitialSessionState(senderInfo);
}
}
}
同樣的方法把它已被使用 - 沒有配置文件PS卡扣在(MyPSSnapin.dll.config)中。但是,我必須刪除配置文件並通過ApplicationArguments傳遞數據。 – Victor 2015-02-10 16:24:44