I had 2 thoughts regarding potential workarounds:
-
When I build this module for testing, I concatenate all the function files into the .psm1, maybe thatâs causing a problem.
-
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