PowerTip: Use Non-Approved Cmdlet or App within PowerShell Workflow


Summary: Learn how to use a basic inline script in Windows PowerShell workflows.

Hey, Scripting Guy! Question I’m trying to convert a Windows PowerShell script to a workflow, but I keep running into an error that suggests
           the cmdlet cannot be used in a workflow. How can I get around this?

Hey, Scripting Guy! Answer Wrap that section of the workflow as an inline script, and recapture your variables with the Using keyword,
           for example:

Inlinescript

            {

            $Somevariable=Using:SomeVariable

            Start-ProblematicFunction $Somevariable

            }

 

Comments (1)

  1. A small comment to all. ‘Twas a typo as the line with Using should be a variable and should read like this

    $Somevariable=$Using:SomeVariable

    Apparently my fingers were moving faster than my brain 🙂

    Sean
    Windows PowerShell MVP
    Honorary Scripting Guy

Skip to main content