// 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 (HotFixId.Expression != null) { targetCommand.AddParameter("Id", HotFixId.Get(context)); } if (Description.Expression != null) { targetCommand.AddParameter("Description", Description.Get(context)); } if (Credential.Expression != null) { targetCommand.AddParameter("Credential", Credential.Get(context)); } if (GetIsComputerNameSpecified(context) && (PSRemotingBehavior.Get(context) == RemotingBehavior.Custom)) { targetCommand.AddParameter("ComputerName", PSComputerName.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
// 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 (AsJob.Expression != null) { targetCommand.AddParameter("AsJob", AsJob.Get(context)); } if (DcomAuthentication.Expression != null) { targetCommand.AddParameter("DcomAuthentication", DcomAuthentication.Get(context)); } if (WsmanAuthentication.Expression != null) { targetCommand.AddParameter("WsmanAuthentication", WsmanAuthentication.Get(context)); } if (Protocol.Expression != null) { targetCommand.AddParameter("Protocol", Protocol.Get(context)); } if (Credential.Expression != null) { targetCommand.AddParameter("Credential", Credential.Get(context)); } if (Impersonation.Expression != null) { targetCommand.AddParameter("Impersonation", Impersonation.Get(context)); } if (ThrottleLimit.Expression != null) { targetCommand.AddParameter("ThrottleLimit", ThrottleLimit.Get(context)); } if (Force.Expression != null) { targetCommand.AddParameter("Force", Force.Get(context)); } if (GetIsComputerNameSpecified(context) && (PSRemotingBehavior.Get(context) == RemotingBehavior.Custom)) { targetCommand.AddParameter("ComputerName", PSComputerName.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
// 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 (PassThru.Expression != null) { targetCommand.AddParameter("PassThru", PassThru.Get(context)); } if (DomainCredential.Expression != null) { targetCommand.AddParameter("DomainCredential", DomainCredential.Get(context)); } if (LocalCredential.Expression != null) { targetCommand.AddParameter("LocalCredential", LocalCredential.Get(context)); } if (NewName.Expression != null) { targetCommand.AddParameter("NewName", NewName.Get(context)); } if (Force.Expression != null) { targetCommand.AddParameter("Force", Force.Get(context)); } if (Restart.Expression != null) { targetCommand.AddParameter("Restart", Restart.Get(context)); } if (WsmanAuthentication.Expression != null) { targetCommand.AddParameter("WsmanAuthentication", WsmanAuthentication.Get(context)); } if (Protocol.Expression != null) { targetCommand.AddParameter("Protocol", Protocol.Get(context)); } if (GetIsComputerNameSpecified(context) && (PSRemotingBehavior.Get(context) == RemotingBehavior.Custom)) { targetCommand.AddParameter("ComputerName", PSComputerName.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
// 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 System.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 (Authentication.Expression != null) { targetCommand.AddParameter("Authentication", Authentication.Get(context)); } if ((ComputerName.Expression != null) && (PSRemotingBehavior.Get(context) != RemotingBehavior.Custom)) { targetCommand.AddParameter("ComputerName", ComputerName.Get(context)); } if (Port.Expression != null) { targetCommand.AddParameter("Port", Port.Get(context)); } if (UseSSL.Expression != null) { targetCommand.AddParameter("UseSSL", UseSSL.Get(context)); } if (ApplicationName.Expression != null) { targetCommand.AddParameter("ApplicationName", ApplicationName.Get(context)); } if (Credential.Expression != null) { targetCommand.AddParameter("Credential", Credential.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 }); }
// 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 System.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 (LogName.Expression != null) { targetCommand.AddParameter("LogName", LogName.Get(context)); } if (Source.Expression != null) { targetCommand.AddParameter("Source", Source.Get(context)); } if (EntryType.Expression != null) { targetCommand.AddParameter("EntryType", EntryType.Get(context)); } if (Category.Expression != null) { targetCommand.AddParameter("Category", Category.Get(context)); } if (EventId.Expression != null) { targetCommand.AddParameter("EventId", EventId.Get(context)); } if (Message.Expression != null) { targetCommand.AddParameter("Message", Message.Get(context)); } if (RawData.Expression != null) { targetCommand.AddParameter("RawData", RawData.Get(context)); } if (GetIsComputerNameSpecified(context) && (PSRemotingBehavior.Get(context) == RemotingBehavior.Custom)) { targetCommand.AddParameter("ComputerName", PSComputerName.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
// 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 (Name.Expression != null) { targetCommand.AddParameter("Name", Name.Get(context)); } if (DependentServices.Expression != null) { targetCommand.AddParameter("DependentServices", DependentServices.Get(context)); } if (RequiredServices.Expression != null) { targetCommand.AddParameter("RequiredServices", RequiredServices.Get(context)); } if (ServiceDisplayName.Expression != null) { targetCommand.AddParameter("DisplayName", ServiceDisplayName.Get(context)); } if (Include.Expression != null) { targetCommand.AddParameter("Include", Include.Get(context)); } if (Exclude.Expression != null) { targetCommand.AddParameter("Exclude", Exclude.Get(context)); } if (InputObject.Expression != null) { targetCommand.AddParameter("InputObject", InputObject.Get(context)); } if (GetIsComputerNameSpecified(context) && (PSRemotingBehavior.Get(context) == RemotingBehavior.Custom)) { targetCommand.AddParameter("ComputerName", PSComputerName.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
protected override List <ActivityImplementationContext> GetImplementation(NativeActivityContext context) { string[] computernames = PSComputerName.Get(context); string[] connectionUris = PSConnectionUri.Get(context); PSSessionOption sessionOptions = PSSessionOption.Get(context); List <ActivityImplementationContext> commands = new List <ActivityImplementationContext>(); // Configure the remote connectivity options RemotingBehavior remotingBehavior = PSRemotingBehavior.Get(context); if (PSRemotingBehavior.Expression == null) { remotingBehavior = RemotingBehavior.PowerShell; } // If they've specified the 'Custom' remoting behavior, ensure the activity // supports it. if ((remotingBehavior == RemotingBehavior.Custom) && (!SupportsCustomRemoting)) { throw new ArgumentException(Resources.CustomRemotingNotSupported); } if (PSCredential.Get(context) != null && PSAuthentication.Get(context) == AuthenticationMechanism.NegotiateWithImplicitCredential) { throw new ArgumentException(Resources.CredentialParameterCannotBeSpecifiedWithNegotiateWithImplicitAuthentication); } // we need connection info to be populated even for the custom remoting case. // This is because the ComputerName is picked up from the connection info field if ((remotingBehavior == RemotingBehavior.PowerShell || (IsActivityInlineScript(this) && RunWithCustomRemoting(context))) && (GetIsComputerNameSpecified(context) || (connectionUris != null && connectionUris.Length > 0))) { List <WSManConnectionInfo> connectionInfo = ActivityUtils.GetConnectionInfo( computernames, connectionUris, PSCertificateThumbprint.Get(context), PSConfigurationName.Get(context), PSUseSsl.Get(context), PSPort.Get(context), PSApplicationName.Get(context), PSCredential.Get(context), PSAuthentication.Get(context).GetValueOrDefault(AuthenticationMechanism.Default), PSAllowRedirection.Get(context).GetValueOrDefault(false), sessionOptions); foreach (WSManConnectionInfo connection in connectionInfo) { CreatePowerShellInstance(context, connection, commands); } } // Configure the local invocation options else { CreatePowerShellInstance(context, null, commands); } return(commands); }
// 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 System.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 (Name.Expression != null) { targetCommand.AddParameter("Name", Name.Get(context)); } if (ProcessId.Expression != null) { targetCommand.AddParameter("Id", ProcessId.Get(context)); } if (InputObject.Expression != null) { targetCommand.AddParameter("InputObject", InputObject.Get(context)); } if (IncludeUserName.Expression != null) { targetCommand.AddParameter("IncludeUserName", IncludeUserName.Get(context)); } if (Module.Expression != null) { targetCommand.AddParameter("Module", Module.Get(context)); } if (FileVersionInfo.Expression != null) { targetCommand.AddParameter("FileVersionInfo", FileVersionInfo.Get(context)); } if (GetIsComputerNameSpecified(context) && (PSRemotingBehavior.Get(context) == RemotingBehavior.Custom)) { targetCommand.AddParameter("ComputerName", PSComputerName.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
// 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 System.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 (ListSet.Expression != null) { targetCommand.AddParameter("ListSet", ListSet.Get(context)); } if (Counter.Expression != null) { targetCommand.AddParameter("Counter", Counter.Get(context)); } if (SampleInterval.Expression != null) { targetCommand.AddParameter("SampleInterval", SampleInterval.Get(context)); } if (MaxSamples.Expression != null) { targetCommand.AddParameter("MaxSamples", MaxSamples.Get(context)); } if (Continuous.Expression != null) { targetCommand.AddParameter("Continuous", Continuous.Get(context)); } if (GetIsComputerNameSpecified(context) && (PSRemotingBehavior.Get(context) == RemotingBehavior.Custom)) { targetCommand.AddParameter("ComputerName", PSComputerName.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
// 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 System.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 (LogName.Expression != null) { targetCommand.AddParameter("LogName", LogName.Get(context)); } if (RetentionDays.Expression != null) { targetCommand.AddParameter("RetentionDays", RetentionDays.Get(context)); } if (OverflowAction.Expression != null) { targetCommand.AddParameter("OverflowAction", OverflowAction.Get(context)); } if (MaximumSize.Expression != null) { targetCommand.AddParameter("MaximumSize", MaximumSize.Get(context)); } if (GetIsComputerNameSpecified(context) && (PSRemotingBehavior.Get(context) == RemotingBehavior.Custom)) { targetCommand.AddParameter("ComputerName", PSComputerName.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
// 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 System.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 (ApplicationName.Expression != null) { targetCommand.AddParameter("ApplicationName", ApplicationName.Get(context)); } if (BasePropertiesOnly.Expression != null) { targetCommand.AddParameter("BasePropertiesOnly", BasePropertiesOnly.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 (Dialect.Expression != null) { targetCommand.AddParameter("Dialect", Dialect.Get(context)); } if (Enumerate.Expression != null) { targetCommand.AddParameter("Enumerate", Enumerate.Get(context)); } if (Filter.Expression != null) { targetCommand.AddParameter("Filter", Filter.Get(context)); } if (Fragment.Expression != null) { targetCommand.AddParameter("Fragment", Fragment.Get(context)); } if (OptionSet.Expression != null) { targetCommand.AddParameter("OptionSet", OptionSet.Get(context)); } if (Port.Expression != null) { targetCommand.AddParameter("Port", Port.Get(context)); } if (Associations.Expression != null) { targetCommand.AddParameter("Associations", Associations.Get(context)); } if (ResourceURI.Expression != null) { targetCommand.AddParameter("ResourceURI", ResourceURI.Get(context)); } if (ReturnType.Expression != null) { targetCommand.AddParameter("ReturnType", ReturnType.Get(context)); } if (SelectorSet.Expression != null) { targetCommand.AddParameter("SelectorSet", SelectorSet.Get(context)); } if (SessionOption.Expression != null) { targetCommand.AddParameter("SessionOption", SessionOption.Get(context)); } if (Shallow.Expression != null) { targetCommand.AddParameter("Shallow", Shallow.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 }); }
// 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 (Job.Expression != null) { targetCommand.AddParameter("Job", Job.Get(context)); } if (Location.Expression != null) { targetCommand.AddParameter("Location", Location.Get(context)); } if (Session.Expression != null) { targetCommand.AddParameter("Session", Session.Get(context)); } if (Keep.Expression != null) { targetCommand.AddParameter("Keep", Keep.Get(context)); } if (NoRecurse.Expression != null) { targetCommand.AddParameter("NoRecurse", NoRecurse.Get(context)); } if (Force.Expression != null) { targetCommand.AddParameter("Force", Force.Get(context)); } if (Wait.Expression != null) { targetCommand.AddParameter("Wait", Wait.Get(context)); } if (AutoRemoveJob.Expression != null) { targetCommand.AddParameter("AutoRemoveJob", AutoRemoveJob.Get(context)); } if (WriteEvents.Expression != null) { targetCommand.AddParameter("WriteEvents", WriteEvents.Get(context)); } if (WriteJobInResults.Expression != null) { targetCommand.AddParameter("WriteJobInResults", WriteJobInResults.Get(context)); } if (Name.Expression != null) { targetCommand.AddParameter("Name", Name.Get(context)); } if (InstanceId.Expression != null) { targetCommand.AddParameter("InstanceId", InstanceId.Get(context)); } if (JobId.Expression != null) { targetCommand.AddParameter("Id", JobId.Get(context)); } if (GetIsComputerNameSpecified(context) && (PSRemotingBehavior.Get(context) == RemotingBehavior.Custom)) { targetCommand.AddParameter("ComputerName", PSComputerName.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
// 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 (ListLog.Expression != null) { targetCommand.AddParameter("ListLog", ListLog.Get(context)); } if (LogName.Expression != null) { targetCommand.AddParameter("LogName", LogName.Get(context)); } if (ListProvider.Expression != null) { targetCommand.AddParameter("ListProvider", ListProvider.Get(context)); } if (ProviderName.Expression != null) { targetCommand.AddParameter("ProviderName", ProviderName.Get(context)); } if (Path.Expression != null) { targetCommand.AddParameter("Path", Path.Get(context)); } if (MaxEvents.Expression != null) { targetCommand.AddParameter("MaxEvents", MaxEvents.Get(context)); } if (Credential.Expression != null) { targetCommand.AddParameter("Credential", Credential.Get(context)); } if (FilterXPath.Expression != null) { targetCommand.AddParameter("FilterXPath", FilterXPath.Get(context)); } if (FilterXml.Expression != null) { targetCommand.AddParameter("FilterXml", FilterXml.Get(context)); } if (FilterHashtable.Expression != null) { targetCommand.AddParameter("FilterHashtable", FilterHashtable.Get(context)); } if (Force.Expression != null) { targetCommand.AddParameter("Force", Force.Get(context)); } if (Oldest.Expression != null) { targetCommand.AddParameter("Oldest", Oldest.Get(context)); } if (GetIsComputerNameSpecified(context) && (PSRemotingBehavior.Get(context) == RemotingBehavior.Custom)) { targetCommand.AddParameter("ComputerName", PSComputerName.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
// 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 (LocalCredential.Expression != null) { targetCommand.AddParameter("LocalCredential", LocalCredential.Get(context)); } if (UnjoinDomainCredential.Expression != null) { targetCommand.AddParameter("UnjoinDomainCredential", UnjoinDomainCredential.Get(context)); } if (Credential.Expression != null) { targetCommand.AddParameter("Credential", Credential.Get(context)); } if (DomainName.Expression != null) { targetCommand.AddParameter("DomainName", DomainName.Get(context)); } if (OUPath.Expression != null) { targetCommand.AddParameter("OUPath", OUPath.Get(context)); } if (Server.Expression != null) { targetCommand.AddParameter("Server", Server.Get(context)); } if (Unsecure.Expression != null) { targetCommand.AddParameter("Unsecure", Unsecure.Get(context)); } if (Options.Expression != null) { targetCommand.AddParameter("Options", Options.Get(context)); } if (WorkgroupName.Expression != null) { targetCommand.AddParameter("WorkgroupName", WorkgroupName.Get(context)); } if (Restart.Expression != null) { targetCommand.AddParameter("Restart", Restart.Get(context)); } if (PassThru.Expression != null) { targetCommand.AddParameter("PassThru", PassThru.Get(context)); } if (NewName.Expression != null) { targetCommand.AddParameter("NewName", NewName.Get(context)); } if (Force.Expression != null) { targetCommand.AddParameter("Force", Force.Get(context)); } if (GetIsComputerNameSpecified(context) && (PSRemotingBehavior.Get(context) == RemotingBehavior.Custom)) { targetCommand.AddParameter("ComputerName", PSComputerName.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
// 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 System.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 (LogName.Expression != null) { targetCommand.AddParameter("LogName", LogName.Get(context)); } if (Newest.Expression != null) { targetCommand.AddParameter("Newest", Newest.Get(context)); } if (After.Expression != null) { targetCommand.AddParameter("After", After.Get(context)); } if (Before.Expression != null) { targetCommand.AddParameter("Before", Before.Get(context)); } if (UserName.Expression != null) { targetCommand.AddParameter("UserName", UserName.Get(context)); } if (InstanceId.Expression != null) { targetCommand.AddParameter("InstanceId", InstanceId.Get(context)); } if (Index.Expression != null) { targetCommand.AddParameter("Index", Index.Get(context)); } if (EntryType.Expression != null) { targetCommand.AddParameter("EntryType", EntryType.Get(context)); } if (Source.Expression != null) { targetCommand.AddParameter("Source", Source.Get(context)); } if (Message.Expression != null) { targetCommand.AddParameter("Message", Message.Get(context)); } if (AsBaseObject.Expression != null) { targetCommand.AddParameter("AsBaseObject", AsBaseObject.Get(context)); } if (List.Expression != null) { targetCommand.AddParameter("List", List.Get(context)); } if (AsString.Expression != null) { targetCommand.AddParameter("AsString", AsString.Get(context)); } if (GetIsComputerNameSpecified(context) && (PSRemotingBehavior.Get(context) == RemotingBehavior.Custom)) { targetCommand.AddParameter("ComputerName", PSComputerName.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }