PowerShell 3.0 を使用してコマンドレットから WWF アクティビティを生成しました。
/// <summary>
/// Activity to invoke the Microsoft.Ceres.HostController.Cmdlets\Connect-Host command in a Workflow.
/// </summary>
[System.CodeDom.Compiler.GeneratedCode("Microsoft.PowerShell.Activities.ActivityGenerator.GenerateFromName", "3.0")]
public sealed class ConnectHost : PSRemotingActivity
{
/// <summary>
/// Gets the display name of the command invoked by this activity.
/// </summary>
public ConnectHost()
{
this.DisplayName = "Connect-Host";
}
/// <summary>
/// Gets the fully qualified name of the command invoked by this activity.
/// </summary>
public override string PSCommandName
{
get { return "Microsoft.Ceres.HostController.Cmdlets\\Connect-Host"; }
}
// Arguments
/// <summary>
/// Provides access to the Host parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.String> Host { get; set; }
/// <summary>
/// Provides access to the Port parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.String> Port { get; set; }
/// <summary>
/// Provides access to the NoConnectionSecurity parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.Management.Automation.SwitchParameter> NoConnectionSecurity { get; set; }
/// <summary>
/// Provides access to the ServiceIdentity parameter.
/// </summary>
[ParameterSpecificCategory]
[DefaultValue(null)]
public InArgument<System.String> ServiceIdentity { get; set; }
// Module defining this command
// Optional custom code for this activity
/// <summary>
/// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
/// </summary>
/// <param name="context">The NativeActivityContext for the currently running activity.</param>
/// <returns>A populated instance of Sytem.Management.Automation.PowerShell</returns>
/// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
{
System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create();
System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);
// Initialize the arguments
if (Host.Expression != null)
{
targetCommand.AddParameter("Host", Host.Get(context));
}
if (Port.Expression != null)
{
targetCommand.AddParameter("Port", Port.Get(context));
}
if (NoConnectionSecurity.Expression != null)
{
targetCommand.AddParameter("NoConnectionSecurity", NoConnectionSecurity.Get(context));
}
if (ServiceIdentity.Expression != null)
{
targetCommand.AddParameter("ServiceIdentity", ServiceIdentity.Get(context));
}
var cont = new ActivityImplementationContext() {PowerShellInstance = invoker};
return cont;
}
}
activity1.xaml を作成したら、「Connect-Host」アクティビティを配置し、開始コードを記述します。
var workflow1 = new Activity1();
WorkflowInvoker.Invoke(workflow1);
しかし、「Microsoft.PowerShell.Workflow.ActivityHostProcess」の型初期化子が例外をスローしました。「パス 'C:\Windows\system32\windowspowershell\v1.0\modules\psworkflow\PSWorkflow.types.ps1xml' の一部が見つかりませんでした。」
しかし、このファイルは私のシステムに存在します。
このテクノロジーをどのように使用できますか?