// // 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.WSMan.Management.Activities { /// /// Activity to invoke the Microsoft.WSMan.Management\Connect-WSMan command in a Workflow. /// [System.CodeDom.Compiler.GeneratedCode("Microsoft.PowerShell.Activities.ActivityGenerator.GenerateFromName", "3.0")] public sealed class ConnectWSMan : PSRemotingActivity { /// /// Gets the display name of the command invoked by this activity. /// public ConnectWSMan() { this.DisplayName = "Connect-WSMan"; } /// /// Gets the fully qualified name of the command invoked by this activity. /// public override string PSCommandName { get { return "Microsoft.WSMan.Management\\Connect-WSMan"; } } // Arguments /// /// Provides access to the ApplicationName parameter. /// [ParameterSpecificCategory] [DefaultValue(null)] public InArgument ApplicationName { get; set; } /// /// Provides access to the ComputerName parameter. /// [ParameterSpecificCategory] [DefaultValue(null)] public InArgument ComputerName { get; set; } /// /// Provides access to the ConnectionURI parameter. /// [ParameterSpecificCategory] [DefaultValue(null)] public InArgument ConnectionURI { get; set; } /// /// Provides access to the OptionSet parameter. /// [ParameterSpecificCategory] [DefaultValue(null)] public InArgument OptionSet { get; set; } /// /// Provides access to the Port parameter. /// [ParameterSpecificCategory] [DefaultValue(null)] public InArgument Port { get; set; } /// /// Provides access to the SessionOption parameter. /// [ParameterSpecificCategory] [DefaultValue(null)] public InArgument SessionOption { get; set; } /// /// Provides access to the UseSSL parameter. /// [ParameterSpecificCategory] [DefaultValue(null)] public InArgument UseSSL { get; set; } /// /// Provides access to the Credential parameter. /// [ParameterSpecificCategory] [DefaultValue(null)] public InArgument Credential { get; set; } /// /// Provides access to the Authentication parameter. /// [ParameterSpecificCategory] [DefaultValue(null)] public InArgument Authentication { get; set; } /// /// Provides access to the CertificateThumbprint parameter. /// [ParameterSpecificCategory] [DefaultValue(null)] public InArgument CertificateThumbprint { get; set; } /// /// Declares that this activity supports its own remoting. /// protected override bool SupportsCustomRemoting { get { return true; } } // 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 Sytem.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(ApplicationName.Expression != null) { targetCommand.AddParameter("ApplicationName", ApplicationName.Get(context)); } if((ComputerName.Expression != null) && (PSRemotingBehavior.Get(context) != RemotingBehavior.Custom)) { targetCommand.AddParameter("ComputerName", ComputerName.Get(context)); } if(ConnectionURI.Expression != null) { targetCommand.AddParameter("ConnectionURI", ConnectionURI.Get(context)); } if(OptionSet.Expression != null) { targetCommand.AddParameter("OptionSet", OptionSet.Get(context)); } if(Port.Expression != null) { targetCommand.AddParameter("Port", Port.Get(context)); } if(SessionOption.Expression != null) { targetCommand.AddParameter("SessionOption", SessionOption.Get(context)); } if(UseSSL.Expression != null) { targetCommand.AddParameter("UseSSL", UseSSL.Get(context)); } if(Credential.Expression != null) { targetCommand.AddParameter("Credential", Credential.Get(context)); } if(Authentication.Expression != null) { targetCommand.AddParameter("Authentication", Authentication.Get(context)); } if(CertificateThumbprint.Expression != null) { targetCommand.AddParameter("CertificateThumbprint", CertificateThumbprint.Get(context)); } if(GetIsComputerNameSpecified(context) && (PSRemotingBehavior.Get(context) == RemotingBehavior.Custom)) { targetCommand.AddParameter("ComputerName", PSComputerName.Get(context)); } return new ActivityImplementationContext() { PowerShellInstance = invoker }; } } }