Martin Schmitt (Customer) asked a question.

Declaring In/Out parameters in Powershell

Hey everyone,

 

I've written a custom Powershell script and would like to declare the parameters such that they show up as Required/In/Out etc. when adding the script to a task. Attached is a screenshot of the built-in "Find or Replace" VB script illustrating how I'd wish it to look like.

 

Unfortunately I can't locate any examples that do this. Any ideas if this is at all possible in Powershell? I have no prior experience with Virtual Basic in MIA, so please forgive my ignorance. 😇

 

Screenshot


  • Vanshdeep Khurana (Progress Software)

    Hi @Martin Schmitt (Customer)​,

     

    Great question, and the screenshot comparison makes sense. But unfortunately, in MOVEit Automation, PowerShell custom scripts can’t declare parameter metadata (Required / In / Out) in the UI the way the built‑in VB scripts do. The “Required/In/Out” descriptors you see are tied to how built‑in scripts are defined/packaged, not something a PowerShell script can expose to the task designer UI.

     

    Workaround

    You can use Task Parameters as your “IN/OUT” mechanism:

    • IN parameters: create Task Parameters in the task step, then read them inside PowerShell using:

    $value = $miaclient.MIGetTaskParam("ParamName")

    We do have a KB that can help you pass the parameter inside the Task -

    URL - https://community.progress.com/s/article/how-to-pass-parameters-to-a-powershell-script

     

    • OUT parameters: write values back for later steps using:

    $miaclient.MISetTaskParam("ParamName", $value)

    I found a similar discussion in the community, which was about the custom variable. Here is the link -

    URL - https://community.progress.com/s/question/0D5Pb00002QYwYMKA1/custom-script-powershell-input-variablesparameters-like-command-line-app

     

    If you want “required” behavior, the usual pattern is to validate in script and set an error (or throw) if a required parameter is empty. This is just an example and not tested -

    $inPath = $miaclient.MIGetTaskParam("InputPath")

    if ([string]::IsNullOrWhiteSpace($inPath)) {

       $miaclient.MILogMsg("InputPath is required but was blank.")

       $miaclient.MISetErrorCode(10000)

       $miaclient.MISetErrorDescription("Missing required parameter: InputPath")

       return

    }

    # … do work …

    $miaclient.MISetTaskParam("OutputValue", $someResult)

     

    So, you won’t get the VB-style “Required/In/Out” labels in the UI for PowerShell scripts, but you can achieve the same functionality reliably via Task Parameters + validation.

     

     

    Let us know if this helps. Thanks

     

     

     

    Regards

    MOVEit Support

  • Martin Schmitt (Customer)

    I already implemented explicit validation as described by you, but was afraid I might be missing a higher-level design pattern. Thank you @Vanshdeep Khurana (Progress Software)​ for the clarification.