For example, I want it to be invoked with -NoProfile flag or maybe with the -File flag, passing our custom profile script.
I may also wish to affect how the output of PowerShell is formatted - right now it seems to be wrapped to 80 characters per line. This is a known behaviour - http://stackoverflow.com/questions/8973577/commandline-syntax-to-prevent-wrapping-in-powershell-output-file, but very inconvenient and I wish to be able to address it.
It all comes down to can I customize the way PowerShell scripts are run?
Thanks for reaching out! Let me break down those questions so I can help you with them:
1) "I want it to be invoked with -NoProfile"
There’s a system variable called
Octopus.Action.PowerShell.ExecuteWithoutProfile that when set to
true It’ll avoid loading any powershell modules sitting on the VM
2) "or maybe with the -File flag, passing our custom profile script"
This is currently possible with a workaround, but its not exactly supported. Its not a bad idea though, so If you’d like to log it into Uservoice that would be great.
The workaround is adding your custom profile script as a Script Module. If you read the gotcha in read in our documentation, you’ll see that the script modules will be loaded with each Powershell sessions, meaning they are basically the same as profile scripts.
3) Command output width
I asked about this to our Dev team and they told me there’s currently no easy way of changing this. If we are going to invest time into researching and implementing a way of changing this, we’ll need to know its something a majority of the community is looking for, for which another Uservoice suggestion would be the perfect place to log this request.
Let me know if you have more questions.