Invoke-PSUScript force script to be executed on current node


I have quite weird case, when primary PS Script should be running in PS7, but part of it only on PS5.
To overcome this - I’m using Invoke-PSUScript. But it’s critical for me to execute both primary and child scripts on same PSU node in cluster. Please advise if it’s possible to achieve this with Invoke-PSUScript?
I saw ComputerName parameter of Invoke-PSUScript, but it’s not very convenient to use, if I just need to ensure that both scripts are running on the same PSU node. Is there any other way to achieve this?

Product: PowerShell Universal
Version: 3.8.7
1 Like

Invoke-PSUScript “Main script” -Computername $env:COMPUTERNAME

then inside Main Script do the same for the secondary script?

It doesn’t work like this easily. but thanks for a hint. Eventually had to construct proper URL from $env:COMPUTERNAME and use AppToken. Not the most elegant solution, as for me, but it works.

This doesn’t actually work. Computername just specify entry point to trigger automation. Internal logic remains unchanged. So, script can be scheduled at any node…
Any other ideas how to make sure scrip is executed on specific node?

We need to add a -Queue parameter to Invoke-PSUScript. If you call the /api/v1/script/{id} POST endpoint, you could do this manually since it’s supported by the API but we should just implement this in the cmdlet since it’s a bit of a pain to get the payload formatted properly.

1 Like