// 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 (ProcessorArchitecture.Expression != null)
            {
                targetCommand.AddParameter("ProcessorArchitecture", ProcessorArchitecture.Get(context));
            }

            if (SessionType.Expression != null)
            {
                targetCommand.AddParameter("SessionType", SessionType.Get(context));
            }

            if (Name.Expression != null)
            {
                targetCommand.AddParameter("Name", Name.Get(context));
            }

            if (AssemblyName.Expression != null)
            {
                targetCommand.AddParameter("AssemblyName", AssemblyName.Get(context));
            }

            if (ApplicationBase.Expression != null)
            {
                targetCommand.AddParameter("ApplicationBase", ApplicationBase.Get(context));
            }

            if (ConfigurationTypeName.Expression != null)
            {
                targetCommand.AddParameter("ConfigurationTypeName", ConfigurationTypeName.Get(context));
            }

            if (RunAsCredential.Expression != null)
            {
                targetCommand.AddParameter("RunAsCredential", RunAsCredential.Get(context));
            }

            if (ThreadApartmentState.Expression != null)
            {
                targetCommand.AddParameter("ThreadApartmentState", ThreadApartmentState.Get(context));
            }

            if (ThreadOptions.Expression != null)
            {
                targetCommand.AddParameter("ThreadOptions", ThreadOptions.Get(context));
            }

            if (AccessMode.Expression != null)
            {
                targetCommand.AddParameter("AccessMode", AccessMode.Get(context));
            }

            if (UseSharedProcess.Expression != null)
            {
                targetCommand.AddParameter("UseSharedProcess", UseSharedProcess.Get(context));
            }

            if (StartupScript.Expression != null)
            {
                targetCommand.AddParameter("StartupScript", StartupScript.Get(context));
            }

            if (MaximumReceivedDataSizePerCommandMB.Expression != null)
            {
                targetCommand.AddParameter("MaximumReceivedDataSizePerCommandMB", MaximumReceivedDataSizePerCommandMB.Get(context));
            }

            if (MaximumReceivedObjectSizeMB.Expression != null)
            {
                targetCommand.AddParameter("MaximumReceivedObjectSizeMB", MaximumReceivedObjectSizeMB.Get(context));
            }

            if (SecurityDescriptorSddl.Expression != null)
            {
                targetCommand.AddParameter("SecurityDescriptorSddl", SecurityDescriptorSddl.Get(context));
            }

            if (ShowSecurityDescriptorUI.Expression != null)
            {
                targetCommand.AddParameter("ShowSecurityDescriptorUI", ShowSecurityDescriptorUI.Get(context));
            }

            if (Force.Expression != null)
            {
                targetCommand.AddParameter("Force", Force.Get(context));
            }

            if (NoServiceRestart.Expression != null)
            {
                targetCommand.AddParameter("NoServiceRestart", NoServiceRestart.Get(context));
            }

            if (PSVersion.Expression != null)
            {
                targetCommand.AddParameter("PSVersion", PSVersion.Get(context));
            }

            if (SessionTypeOption.Expression != null)
            {
                targetCommand.AddParameter("SessionTypeOption", SessionTypeOption.Get(context));
            }

            if (TransportOption.Expression != null)
            {
                targetCommand.AddParameter("TransportOption", TransportOption.Get(context));
            }

            if (ModulesToImport.Expression != null)
            {
                targetCommand.AddParameter("ModulesToImport", ModulesToImport.Get(context));
            }

            if (Path.Expression != null)
            {
                targetCommand.AddParameter("Path", Path.Get(context));
            }


            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }
Beispiel #2
0
        // 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 (Path.Expression != null)
            {
                targetCommand.AddParameter("Path", Path.Get(context));
            }

            if (NestedModules.Expression != null)
            {
                targetCommand.AddParameter("NestedModules", NestedModules.Get(context));
            }

            if (Guid.Expression != null)
            {
                targetCommand.AddParameter("Guid", Guid.Get(context));
            }

            if (Author.Expression != null)
            {
                targetCommand.AddParameter("Author", Author.Get(context));
            }

            if (CompanyName.Expression != null)
            {
                targetCommand.AddParameter("CompanyName", CompanyName.Get(context));
            }

            if (Copyright.Expression != null)
            {
                targetCommand.AddParameter("Copyright", Copyright.Get(context));
            }

            if (RootModule.Expression != null)
            {
                targetCommand.AddParameter("RootModule", RootModule.Get(context));
            }

            if (ModuleVersion.Expression != null)
            {
                targetCommand.AddParameter("ModuleVersion", ModuleVersion.Get(context));
            }

            if (Description.Expression != null)
            {
                targetCommand.AddParameter("Description", Description.Get(context));
            }

            if (ProcessorArchitecture.Expression != null)
            {
                targetCommand.AddParameter("ProcessorArchitecture", ProcessorArchitecture.Get(context));
            }

            if (PowerShellVersion.Expression != null)
            {
                targetCommand.AddParameter("PowerShellVersion", PowerShellVersion.Get(context));
            }

            if (ClrVersion.Expression != null)
            {
                targetCommand.AddParameter("ClrVersion", ClrVersion.Get(context));
            }

            if (DotNetFrameworkVersion.Expression != null)
            {
                targetCommand.AddParameter("DotNetFrameworkVersion", DotNetFrameworkVersion.Get(context));
            }

            if (PowerShellHostName.Expression != null)
            {
                targetCommand.AddParameter("PowerShellHostName", PowerShellHostName.Get(context));
            }

            if (PowerShellHostVersion.Expression != null)
            {
                targetCommand.AddParameter("PowerShellHostVersion", PowerShellHostVersion.Get(context));
            }

            if (RequiredModules.Expression != null)
            {
                targetCommand.AddParameter("RequiredModules", RequiredModules.Get(context));
            }

            if (TypesToProcess.Expression != null)
            {
                targetCommand.AddParameter("TypesToProcess", TypesToProcess.Get(context));
            }

            if (FormatsToProcess.Expression != null)
            {
                targetCommand.AddParameter("FormatsToProcess", FormatsToProcess.Get(context));
            }

            if (ScriptsToProcess.Expression != null)
            {
                targetCommand.AddParameter("ScriptsToProcess", ScriptsToProcess.Get(context));
            }

            if (RequiredAssemblies.Expression != null)
            {
                targetCommand.AddParameter("RequiredAssemblies", RequiredAssemblies.Get(context));
            }

            if (FileList.Expression != null)
            {
                targetCommand.AddParameter("FileList", FileList.Get(context));
            }

            if (ModuleList.Expression != null)
            {
                targetCommand.AddParameter("ModuleList", ModuleList.Get(context));
            }

            if (FunctionsToExport.Expression != null)
            {
                targetCommand.AddParameter("FunctionsToExport", FunctionsToExport.Get(context));
            }

            if (AliasesToExport.Expression != null)
            {
                targetCommand.AddParameter("AliasesToExport", AliasesToExport.Get(context));
            }

            if (VariablesToExport.Expression != null)
            {
                targetCommand.AddParameter("VariablesToExport", VariablesToExport.Get(context));
            }

            if (CmdletsToExport.Expression != null)
            {
                targetCommand.AddParameter("CmdletsToExport", CmdletsToExport.Get(context));
            }

            if (DscResourcesToExport.Expression != null)
            {
                targetCommand.AddParameter("DscResourcesToExport", DscResourcesToExport.Get(context));
            }

            if (PrivateData.Expression != null)
            {
                targetCommand.AddParameter("PrivateData", PrivateData.Get(context));
            }

            if (Tags.Expression != null)
            {
                targetCommand.AddParameter("Tags", Tags.Get(context));
            }

            if (ProjectUri.Expression != null)
            {
                targetCommand.AddParameter("ProjectUri", ProjectUri.Get(context));
            }

            if (LicenseUri.Expression != null)
            {
                targetCommand.AddParameter("LicenseUri", LicenseUri.Get(context));
            }

            if (IconUri.Expression != null)
            {
                targetCommand.AddParameter("IconUri", IconUri.Get(context));
            }

            if (ReleaseNotes.Expression != null)
            {
                targetCommand.AddParameter("ReleaseNotes", ReleaseNotes.Get(context));
            }

            if (HelpInfoUri.Expression != null)
            {
                targetCommand.AddParameter("HelpInfoUri", HelpInfoUri.Get(context));
            }

            if (PassThru.Expression != null)
            {
                targetCommand.AddParameter("PassThru", PassThru.Get(context));
            }

            if (DefaultCommandPrefix.Expression != null)
            {
                targetCommand.AddParameter("DefaultCommandPrefix", DefaultCommandPrefix.Get(context));
            }


            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }