HelpCache/Microsoft.Powershell.Workflow.ServiceCore.dll-help.xml

<?xml version="1.0" encoding="utf-8"?>
<helpItems xmlns="http://msh" schema="maml">
  <!-- Updatable Help Version 5.0.1.0 -->
  <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp">
    <command:details>
      <command:name>Invoke-AsWorkflow</command:name>
      <maml:description>
        <maml:para>Runs a command or expression as a Windows PowerShell Workflow.</maml:para>
      </maml:description>
      <maml:copyright>
        <maml:para />
      </maml:copyright>
      <command:verb>Invoke</command:verb>
      <command:noun>AsWorkflow</command:noun>
      <dev:version />
    </command:details>
    <maml:description>
      <maml:para>The Invoke-AsWorkflow workflow runs any command or expression as an inline script in a workflow. These workflows use the standard workflow semantics, have all workflow common parameters, and have all benefits of workflows, including the ability to stop, resume, and recover.</maml:para>
      <maml:para>Workflows are designed for long-running commands that collect critical data, but can be used to run any command. For more information, see about_Workflows.</maml:para>
      <maml:para>You can also add workflow common parameters to this command. For more information about workflow common parameters, see <maml:navigationLink><maml:linkText>about_WorkflowCommonParameters</maml:linkText><maml:uri></maml:uri></maml:navigationLink>.</maml:para>
      <maml:para>This workflow is introduced in Windows PowerShell 3.0.</maml:para>
    </maml:description>
    <command:syntax>
      <command:syntaxItem>
        <maml:name>Invoke-AsWorkflow</maml:name>
        <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="">
          <maml:name>CommandName</maml:name>
          <maml:description>
            <maml:para>Runs the specified cmdlet or advanced function as a workflow. Enter the cmdlet or function name, such as Update-Help, Set-ExecutionPolicy, or Set-NetFirewallRule.</maml:para>
          </maml:description>
          <command:parameterValue required="true" variableLength="false">String</command:parameterValue>
        </command:parameter>
        <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="">
          <maml:name>Parameter</maml:name>
          <maml:description>
            <maml:para>Specifies the parameters and parameter values of the command that is specified in the CommandName parameter. Enter a hash table in which each key is a parameter name and its value is the parameter value, such as @{ExecutionPolicy="AllSigned"}.</maml:para>
            <maml:para>For information about hash tables, see about_Hash_Tables (http://go.microsoft.com/fwlink/?LinkID=135175).</maml:para>
          </maml:description>
          <command:parameterValue required="true" variableLength="false">Hashtable</command:parameterValue>
        </command:parameter>
      </command:syntaxItem>
      <command:syntaxItem>
        <maml:name>Invoke-AsWorkflow</maml:name>
        <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="">
          <maml:name>Expression</maml:name>
          <maml:description>
            <maml:para>Runs the specified expression as a workflow. Enter the expression as a string, such as "ipconfig /all". If the expression includes spaces or special characters, enclose the expression in quotation marks.</maml:para>
          </maml:description>
          <command:parameterValue required="true" variableLength="false">String</command:parameterValue>
        </command:parameter>
      </command:syntaxItem>
    </command:syntax>
    <command:parameters>
      <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="">
        <maml:name>CommandName</maml:name>
        <maml:description>
          <maml:para>Runs the specified cmdlet or advanced function as a workflow. Enter the cmdlet or function name, such as Update-Help, Set-ExecutionPolicy, or Set-NetFirewallRule.</maml:para>
        </maml:description>
        <command:parameterValue required="true" variableLength="false">String</command:parameterValue>
        <dev:type>
          <maml:name>String</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue>None</dev:defaultValue>
      </command:parameter>
      <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="">
        <maml:name>Expression</maml:name>
        <maml:description>
          <maml:para>Runs the specified expression as a workflow. Enter the expression as a string, such as "ipconfig /all". If the expression includes spaces or special characters, enclose the expression in quotation marks.</maml:para>
        </maml:description>
        <command:parameterValue required="true" variableLength="false">String</command:parameterValue>
        <dev:type>
          <maml:name>String</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue>None</dev:defaultValue>
      </command:parameter>
      <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="">
        <maml:name>Parameter</maml:name>
        <maml:description>
          <maml:para>Specifies the parameters and parameter values of the command that is specified in the CommandName parameter. Enter a hash table in which each key is a parameter name and its value is the parameter value, such as @{ExecutionPolicy="AllSigned"}.</maml:para>
          <maml:para>For information about hash tables, see about_Hash_Tables (http://go.microsoft.com/fwlink/?LinkID=135175).</maml:para>
        </maml:description>
        <command:parameterValue required="true" variableLength="false">Hashtable</command:parameterValue>
        <dev:type>
          <maml:name>Hashtable</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue>None</dev:defaultValue>
      </command:parameter>
    </command:parameters>
    <command:inputTypes>
      <command:inputType>
        <dev:type>
          <maml:name>System.Object</maml:name>
          <maml:uri>
          </maml:uri>
          <maml:description>
            <maml:para />
          </maml:description>
        </dev:type>
        <maml:description>
          <maml:para>You can pipe any object to the InputObject workflow common parameter. For information, see about_WorkflowCommonParameters (http://go.microsoft.com/fwlink/?LinkID=222527).</maml:para>
        </maml:description>
      </command:inputType>
    </command:inputTypes>
    <command:returnValues>
      <command:returnValue>
        <dev:type>
          <maml:name>None</maml:name>
          <maml:uri>
          </maml:uri>
          <maml:description>
            <maml:para />
          </maml:description>
        </dev:type>
        <maml:description>
          <maml:para>This command does not generate any output. However, it runs the workflow, which might generate output.</maml:para>
        </maml:description>
      </command:returnValue>
    </command:returnValues>
    <command:terminatingErrors />
    <command:nonTerminatingErrors />
    <command:examples>
      <command:example>
        <maml:title>Example 1: Run a cmdlet as a workflow</maml:title>
        <maml:introduction>
          <maml:para>
          </maml:para>
        </maml:introduction>
        <dev:code>PS C:\&gt;Invoke-AsWorkflow -CommandName Get-ExecutionPolicy -PSComputerName (Get-Content Servers.txt)
 
PSComputerName PSSourceJobInstanceId Value
 
-------------- --------------------- -----
 
Server01 77b1cdf8-8226-4662-9067-cd2fa5c3b711 AllSigned
 
Server02 a33542d7-3cdd-4339-ab99-0e7cd8e59462 Unrestricted
 
Server03 279bac28-066a-4646-9497-8fcdcfe9757e AllSigned
 
localhost 0d858009-2cc4-47a4-a2e0-da17dc2883d0 RemoteSigned
 

</dev:code>
        <dev:remarks>
          <maml:para>This command runs the Get-ExecutionPolicy cmdlet as a workflow on hundreds of computers.</maml:para>
          <maml:para>The command uses the CommandName parameter to specify the cmdlet that runs in the workflow. It uses the PSComputerName workflow common parameter to specify the computers on which the command runs. The value of the PSComputerName parameter is a Get-Content command that gets a list of computer names from the Servers.txt file. The parameter value is enclosed in parentheses to direct Windows PowerShell to run the Get-Command command before using the value.</maml:para>
          <maml:para>As with all remote commands, if the command runs on the local computer, (if the value of the PSComputerName parameter includes the local computer), you must start Windows PowerShell with the "Run as administrator" option.</maml:para>
        </dev:remarks>
        <command:commandLines>
          <command:commandLine>
            <command:commandText />
          </command:commandLine>
        </command:commandLines>
      </command:example>
      <command:example>
        <maml:title>Example 2: Run a cmdlet with parameters</maml:title>
        <maml:introduction>
          <maml:para>
          </maml:para>
        </maml:introduction>
        <dev:code>The first command uses the Import-Csv cmdlet to create an object from the content in the Servers.csv file. The command uses the Header parameter to create a ServerName property for the column that contains the names of the target computers, also known as "remote nodes." The command saves the result in the $s variable.
PS C:\&gt;$s = Import-Csv .\Servers.csv -Header ServerName, ServerID
 
 
The second command uses the Invoke-AsWorkflow workflow to run a Get-ExecutionPolicy command on the computers in the Servers.csv file.The command uses the CommandName parameter of Invoke-AsWorkflow to specify the command to run in the workflow. It uses the Parameter parameter of Invoke-AsWorkflow to specify the Scope parameter of the Get-ExecutionPolicy cmdlet with a value of Process.The command also uses the PSConnectionRetryCount workflow common parameter to limit the command to five attempts on each computer and the PSComputerName workflow common parameter to specify the names of the remote nodes (target computers). The value of the PSComputerName parameter is an expression that gets the ServerName property of every object in the $s variable.
PS C:\&gt;Invoke-AsWorkflow -CommandName Get-ExecutionPolicy -Parameter @{Scope="Process"} -PSComputerName {$s.ServerName}-PSConnectionRetryCount 5
</dev:code>
        <dev:remarks>
          <maml:para>These commands run a Get-ExecutionPolicy command as a workflow on hundreds of computers. The command uses the Scope parameter of the Get-ExecutionPolicy cmdlet with a value of Process to get the execution policy in the current session.</maml:para>
        </dev:remarks>
        <command:commandLines>
          <command:commandLine>
            <command:commandText />
          </command:commandLine>
        </command:commandLines>
      </command:example>
      <command:example>
        <maml:title>Example 3: Run an expression as a workflow</maml:title>
        <maml:introduction>
          <maml:para>
          </maml:para>
        </maml:introduction>
        <dev:code>PS C:\&gt;Invoke-AsWorkflow -Expression "ipconfig /all" -PSComputerName (Get-Content DomainControllers.txt) -AsJob -JobName IPConfig
 
Id Name PSJobTypeName State HasMoreData Location Command
 
-- ---- ------------- ----- ----------- -------- -------
 
2 IpConfig PSWorkflowJob Completed True Server01, Server01... Invoke-AsWorkflow
</dev:code>
        <dev:remarks>
          <maml:para>This command uses the Invoke-AsWorkflow workflow to run an Ipconfig command as a workflow job on the computers listed in the DomainControllers.txt file.</maml:para>
          <maml:para>The command uses the Expression parameter to specify the expression to run. It uses the PSComputerName workflow common parameter to specify the names of the remote nodes (target computers).</maml:para>
          <maml:para>The command also uses the AsJob and JobName workflow common parameters to run the workflow as a background job on each computer with the "Ipconfig" job name.</maml:para>
          <maml:para>The command returns a ContainerParentJob object (System.Management.Automation.ContainerParentJob) that contains the workflow jobs on each computer.</maml:para>
        </dev:remarks>
        <command:commandLines>
          <command:commandLine>
            <command:commandText />
          </command:commandLine>
        </command:commandLines>
      </command:example>
    </command:examples>
    <maml:relatedLinks>
      <maml:navigationLink>
        <maml:linkText>Online Version:</maml:linkText>
        <maml:uri>http://go.microsoft.com/fwlink/p/?linkid=287544</maml:uri>
      </maml:navigationLink>
      <maml:navigationLink>
        <maml:linkText>New-PSWorkflowExecutionOption</maml:linkText>
        <maml:uri />
      </maml:navigationLink>
      <maml:navigationLink>
        <maml:linkText>New-PSWorkflowSession</maml:linkText>
        <maml:uri />
      </maml:navigationLink>
      <maml:navigationLink>
        <maml:linkText>about_Workflows</maml:linkText>
        <maml:uri />
      </maml:navigationLink>
      <maml:navigationLink>
        <maml:linkText>about_Workflow_Common_Parameters</maml:linkText>
        <maml:uri />
      </maml:navigationLink>
      <maml:navigationLink>
        <maml:linkText>Windows PowerShell Workflow Module</maml:linkText>
        <maml:uri />
      </maml:navigationLink>
      <maml:navigationLink>
        <maml:linkText>Windows PowerShell Workflow Utility Module</maml:linkText>
        <maml:uri />
      </maml:navigationLink>
    </maml:relatedLinks>
  </command:command>
</helpItems>