I have a powershell script called “cleanupFiles.ps1” and i need to run this on multiple Octopus environments using script console. is there any way we can run a Power Shell script via script console remotely ?
I prefer to use PowerShell to call/invoke Octopus Script Console to execute another powershell script.
Thanks for getting in touch! While it’s possible to run an adhoc script using the console via the API, I don’t think it would be the most straight forward way, and I may suggest an easier approach. However, I found a sample script using the Octopus.Client (an open source .NET library) which may get you started with this approach.
What would be easiest is to run it via the web portal, or zip up your script file and deploy it to invoke it where you need to run it.
I hope this helps! Let me know how you go or if you have any further questions.