How can I configure the way octopus invokes powershell to run the PowerShell scripts?

mark.kharitonov's Avatar

mark.kharitonov

17 May, 2017 03:51 PM

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?

  1. Support Staff 1 Posted by Dalmiro Grañas on 18 May, 2017 05:14 PM

    Dalmiro Grañas's Avatar

    Hi Mark,

    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.

    Regards,
    Dalmiro

  2. Paul Stovell closed this discussion on 26 Aug, 2017 03:33 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac