New-PSUScript -Module -Command not showing parameters

Product: PowerShell Universal
Version: 4.2.20

I created a module with functions to expose as a script using New-PSUScript with Module/Command. The function executes as expected but the parameters are not shown on the run screen but does prompt for each one after the fact while running one by one. Copying and pasting the same code to a dedicated ps1 without the function block has the parameters shown as expected. Below is a sample line that does not seem to work as intended. Am I missing something?

New-PSUScript -Description "New Account" -Module 'PSUFunctions' -Command 'New-PSUADStaff' -Environment "Dev" -Tag @('Staff','Account')

Thanks.

1 Like

I’m have the same behavior in 5.2.1

The function is available as a gist: Invoke-IamWorkflow ¡ GitHub

Content of \Modules\PowerIAM.universal\scripts.ps1

New-PSUScript -Module 'PowerIAM' -Command 'Invoke-IamWorkflow' -Environment 'PowerIAM' -Description "Runs PowerIAM workflow scripts."

Viewing the script in the UI, there are no parameters, and when using Get-PSUScript there are also no Parameters shown. Attempting to execute the command results in Awaiting Feedback, as the input parameters are mandatory.

Example script call:

Invoke-PSUScript -Script (Get-PSUScript -Name 'PowerIAM\Invoke-IamWorkflow') -Parameters @{ InputObject = 'g000003'; Workers = @('NewIWF')}

I had 2 thoughts regarding potential workarounds:

  1. When I build this module for testing, I concatenate all the function files into the .psm1, maybe that’s causing a problem.

  2. Maybe there’s something wrong with using module functions altogether, which could be tested by converting the function to a scriptblock and adding int scripts.ps1 but I took that a step further and made a very simple script for testing:

param(
    $name
)

Write-Host "Hello $name!"

Scenario 1: Per-File Functions - Test and Results

To test scenario 1, I modified my build process to not concatenate the function files, so that each function exported by the module was its own file in \Public, then built the module and copied to my test server.

After restarting the PowerShell Universal service and checking out Automation\Scripts, I could see the new script there, but when clicking on the button to execute the script, there was no Parameters tab, which is the same behavior from before, as pictured below.

Ok, that was a bust, on to test scenario 2.

Scenario 2: Simple Scripblock - Test and Results

In this case I added a script to the module and updated scripts.ps1 to publish the script.

The script to be published:

param(
    $name
)

Write-Host "Hello $name!"

scripts.ps1 entry:

New-PSUScript -Name 'TestScript' -Path "$Repository\modules\PowerIAM\app\scripts\testScript.ps1"

After building the module and deploying to the server, the new script, TestScript was able to be seen in Automation\Scripts, but was exhibiting the same behavior, no Parameters tab.

Get-PSUScript was also not returning any script parameters.

Get-PSUScript Output - Scenario 2

Id                        : 4
Name                      : TestScript
OldName                   : 
Description               : 
CreatedTime               : 1/1/0001 12:00:00 AM
ManualTime                : 0
TimeOut                   : 0
CommitId                  : 
Content                   : 
ScriptParameters          : 
Identity                  : 
Status                    : Draft
Tags                      : 
Tag                       : 
FullPath                  : D:\UniversalAutomation\Repository\Modules\PowerIAM\modules\PowerIAM\app\scripts\testScript.ps1
RequiredPowerShellVersion : 
Environment               : PowerIAM
ErrorAction               : Continue
InformationAction         : Continue
Verbose                   : False
Debug                     : False
CommitNotes               : 
DisableManualInvocation   : False
MaxHistory                : 100
ConcurrentJobs            : 100
Credential                : 
RetryLimit                : 0
DiscardPipeline           : False
LongDescription           : 
Links                     : 
Examples                  : 
DefaultParameterSet       : 
LoadProfile               : False
WorkingDirectory          : 
ParameterSets             : 
ReadOnly                  : True
Module                    : PowerIAM
Command                   : 
Role                      : {}
Roles                     : {}
Documentation             : 
PreviousContent           : 
Folder                    : 
FolderId                  : 
PortalOutputType          : None
AvailableInBranch         : {}
FolderPath                : D:\UniversalAutomation\Repository\Modules\PowerIAM\modules\PowerIAM\app\scripts
AvailableInBranches       : {}
Resource                  : 
ReadPermission            : 

Scenario 3: Sanity Check
At this point I created a new script from the PSU GUI and published it. I used the same simple scriptblock from before:

param(
    $name
)

Write-Host "Hello $name!"

Now, the parameters tab is available, and I can see parameters in the UI.

Using Get-PSUScript also finally returns an entry for Parameters.

Get-PSUScript Output - Sanity Check

Id                        : 5
Name                      : TestScript_Local.ps1
OldName                   : 
Description               : TestScript_Local.ps1
CreatedTime               : 2/8/2025 4:31:36 PM
ManualTime                : 0
TimeOut                   : 0
CommitId                  : 
Content                   : param(
                                $name
                            )
                            
                            Write-Host "Hello, $name!"
ScriptParameters          : {name}
Identity                  : 
Status                    : Draft
Tags                      : 
Tag                       : 
FullPath                  : TestScript_Local.ps1
RequiredPowerShellVersion : 
Environment               : PowerIAM
ErrorAction               : Continue
InformationAction         : Continue
Verbose                   : False
Debug                     : False
CommitNotes               : 
DisableManualInvocation   : False
MaxHistory                : 100
ConcurrentJobs            : 100
Credential                : 
RetryLimit                : 0
DiscardPipeline           : False
LongDescription           : 
Links                     : 
Examples                  : 
DefaultParameterSet       : 
LoadProfile               : False
WorkingDirectory          : 
ParameterSets             : {Default}
ReadOnly                  : False
Module                    : 
Command                   : 
Role                      : {}
Roles                     : {}
Documentation             : 
PreviousContent           : 
Folder                    : 
FolderId                  : 
PortalOutputType          : None
AvailableInBranch         : {}
FolderPath                : 
AvailableInBranches       : {}
Resource                  : 
ReadPermission            : 

Summary:

It appears this is a bug in how module-based scripts are being handled. The test environment I’m using is a completely new install of Windows Server 2022 Datacenter with PowerShell Universal 5.2.3

Edit: I have opened an issue for this: Parameters missing from module-based scripts. ¡ Issue #4357 ¡ ironmansoftware/powershell-universal ¡ GitHub

I have the same issue also on 5.2.1

Everything works when i run:
Invoke-PSUScript -Name “MyScript.ps1” -Parameters @{‘ID’ = 1} -Queue “PSUServer01”

It asks for “ID” when i run:
Invoke-PSUScript -Name “MyModule\MyScript” -Parameters @{‘ID’ = 1} -Queue “PSUServer01”