In the clean install of PSU 5.0.5 I stood up earlier for my testing, I’ve now found that Invoke-PSUScript
seems to have an issue with locating scripts or accessing scripts when using the -Script
operator.
If I create a script at the root of my repository (let’s name it Testing.ps1
), and I then reference the script in an Endpoint via Invoke-PSUScript -Name 'Testing.ps1' - TrustCertificate
the invokation runs without an issue.
If I create a script in a subfolder of my repository (for example, the folder is named Test Scripts
, and the script is named Testing.ps1
), and I reference it in an Endpoint via Invoke-PSUScript -Name 'Test Scripts\Testing.ps1' - TrustCertificate
the invokation fails because -Name
doesn’t support paths/folders (you get Cannot retrieve the dynamic parameters for the cmdlet. Unknown script: Testing\Testing.ps1
if you attempt to use a folder).
Given that -Name
doesn’t support paths/folders, if I were to have 2 scripts named identically but in different folders, I would never be assured of which script the -Name
operator would end up running, so this leaves me with having to use the -Script
operator instead and illuminates its new (as of 5.0.x) behavior.
If I create a script in a folder or subfolder of my repository (for example, the folder is named Test Scripts
, and the script is named Testing.ps1
), and I reference it in an Endpoint via Invoke-PSUScript -Script 'Test Scripts\Testing.ps1' - TrustCertificate
I get the error Cannot retrieve the dynamic parameters for the cmdlet. Object reference not set to an instance of an object.
when accessing the API.
Did something change from 4.x to 5.x in regard to Invoke-PSUScript
?
For reference, I’ve already tried variations of the path without any success.
Product: PowerShell Universal
Version: 5.0.5