// // Copyright (C) Microsoft. All rights reserved. // using Microsoft.PowerShell.Activities; using System.Management.Automation; using System.Activities; using System.Collections.Generic; using System.ComponentModel; namespace Microsoft.PowerShell.Core.Activities { /// /// Activity to invoke the Microsoft.PowerShell.Core\Remove-PSSession command in a Workflow. /// [System.CodeDom.Compiler.GeneratedCode("Microsoft.PowerShell.Activities.ActivityGenerator.GenerateFromName", "3.0")] public sealed class RemovePSSession : PSRemotingActivity { /// /// Gets the display name of the command invoked by this activity. /// public RemovePSSession() { this.DisplayName = "Remove-PSSession"; } /// /// Gets the fully qualified name of the command invoked by this activity. /// public override string PSCommandName { get { return "Microsoft.PowerShell.Core\\Remove-PSSession"; } } // Arguments /// /// Provides access to the Session parameter. /// [ParameterSpecificCategory] [DefaultValue(null)] public InArgument Session { get; set; } /// /// Provides access to the ContainerId parameter. /// [ParameterSpecificCategory] [DefaultValue(null)] public InArgument ContainerId { get; set; } /// /// Provides access to the VMId parameter. /// [ParameterSpecificCategory] [DefaultValue(null)] public InArgument VMId { get; set; } /// /// Provides access to the VMName parameter. /// [ParameterSpecificCategory] [DefaultValue(null)] public InArgument VMName { get; set; } /// /// Provides access to the InstanceId parameter. /// [ParameterSpecificCategory] [DefaultValue(null)] public InArgument InstanceId { get; set; } /// /// Provides access to the PSSessionId parameter. /// [ParameterSpecificCategory] [DefaultValue(null)] public InArgument PSSessionId { get; set; } /// /// Provides access to the Name parameter. /// [ParameterSpecificCategory] [DefaultValue(null)] public InArgument Name { get; set; } /// /// Provides access to the ComputerName parameter. /// [ParameterSpecificCategory] [DefaultValue(null)] public InArgument ComputerName { get; set; } // Module defining this command // Optional custom code for this activity /// /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run. /// /// The NativeActivityContext for the currently running activity. /// A populated instance of System.Management.Automation.PowerShell /// The infrastructure takes responsibility for closing and disposing the PowerShell instance returned. 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(Session.Expression != null) { targetCommand.AddParameter("Session", Session.Get(context)); } if(ContainerId.Expression != null) { targetCommand.AddParameter("ContainerId", ContainerId.Get(context)); } if(VMId.Expression != null) { targetCommand.AddParameter("VMId", VMId.Get(context)); } if(VMName.Expression != null) { targetCommand.AddParameter("VMName", VMName.Get(context)); } if(InstanceId.Expression != null) { targetCommand.AddParameter("InstanceId", InstanceId.Get(context)); } if(PSSessionId.Expression != null) { targetCommand.AddParameter("Id", PSSessionId.Get(context)); } if(Name.Expression != null) { targetCommand.AddParameter("Name", Name.Get(context)); } if(ComputerName.Expression != null) { targetCommand.AddParameter("ComputerName", ComputerName.Get(context)); } return new ActivityImplementationContext() { PowerShellInstance = invoker }; } } }