Set CharSet from PS1 execution

Hi,

I encounter some troubles executing a powershell script during deployment.
My goal is to use SqlPlus to execute some sql scipts on my DB, but, because i got some special chars, I must set a specific code page and nls_lang…

I am able to make this work when i’m connected remotly to my server, but when i copy my powershell script on an octopus powershell process, some commands don’t work :

Invoke-Expression “chcp”
this command should print the current Active code page but i can’t retrieve the value neither set the new one.

It might be due to the account executing the script while deploying?
Can anyone give me an hint on that please?

Hi Steve,

Welcome to the community :slight_smile: Are you able to send me the error you get while running that command? Perhaps the task logs as well.

I just tried running it myself on a test server and it worked OK. I doubt it would be a permissions issue. Here are some screenshots of the output + config of how I ran the command.

Hi Chris,

Thank you :slightly_smiling_face:

I reproduce your simple test, with this result :


image

I have no output.
In my previous script i had :

$chcp = Invoke-Expression “chcp”
write-host “Current Active code page : $chcp”

and it printed :

Current Active code page :

The only difference i see is in the execution plan :

Octopus Server VS Deployment Target

with the OctopusServer I got :
image

Strange… What version of Octopus Server are you running?

It 's not the latest :
image

OK, no worries. Here’s a couple of ideas we can try. Instead of using Invoke-Expression, can you tell me if either of these variants give you any output?

& cmd /c chcp
or…
Start-Process -FilePath "cmd" -ArgumentList "/c chcp" -NoNewWindow -Wait

Another thing, what OS are you running?

The account in which your tasks run as, does it have local administrative permissions or is it restricted?

Hi,

Our system is a windows server 2008 R2,
and the tentacle service is running as LocalSystem.

& cmd /c chcp

this works locally but still no output in deployment

Start-Process -FilePath “cmd” -ArgumentList “/c chcp” -NoNewWindow -Wait

This does not work locally

Would you mind checking the verbose logs and sending them through to me?

You can get them by browsing to your task, clicking on Task Log, and then selecting Verbose from the log level dropdown menu.

of course : (process with : & cmd /c chcp)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.