# Updating variables in file using the run powershell script step

#### martenolofsson

04 Feb, 2018 04:40 PM

Hi,

I have an application which is deployed to azure through octopus deploy. It contains two steps, the first is to run a console application, IE trigger an EXE file through powershell. In the package where the exe exists there is also a config file which is used by the application. Is there a way to replace variables in this file before the exe is executed in the same way I can replace variables in file while using the deploy a nuget package step?

Best,
Mårten Olofsson

1. Support Staff Posted by Reece Walsh on 05 Feb, 2018 05:29 AM

Hi Mårten,

Thanks for getting back to me regarding this,

It's definitely possible to replace the variables in this config file using the Configuration Variables feature.

Using this feature, it's also possible to replace settings that exist outside of appSettings, applicationSettings and connectionStrings.

This method will work provided the EXE file you specified, is also contained within the package being deployed.

I hope this helps!

If you require further information or clarification please let me know :)

Kind Regards,

Reece

2. Posted by martenolofsson on 05 Feb, 2018 09:00 AM

Hi Reece,

I know that this feature is available when for example deploying a webapp, but I want to do this using the "run a script" template. As far as I can see the "features" section is not available then.

Best,
Mårten

3. Support Staff Posted by Reece Walsh on 06 Feb, 2018 03:39 AM

Hi Mårten,

Thanks for getting back to me regarding this,

It sounds like you are wanting to substitute a variable in a file that's not in a package being deployed.

In that scenario, you could try specifying an absolute path in the substitute variables in files feature (i.e. C:\Octopus\text.txt), since this is only a feature of package steps, not script steps. You could potentially deploy an empty dummy package to utilize this feature.

All of the supported scenarios can be found within the Advanced Configuration Transforms Examples area of our documentation.

If I've misunderstood in any way or you require further assistance please let me know :)

Kind Regards,

Reece

4. Posted by martenolofsson on 15 Feb, 2018 03:03 PM

Hi Reece,

Actually, what my scenario looks this :I have a package that I'm deploying but as one step of the process I want to run a script which invokes a console application (exe) (which is located in another package with the same id - not really my prefered approach but....) and that application has a config file in which I want to update some variables before executing the script.

What exactly do you mean when you say "deploy and empty dummy package"? Using a "deploy a package" to get hold of the configuration variables feature but not actually deploy a package?

Kind Regards,

Mårten

5. Support Staff Posted by Reece Walsh on 16 Feb, 2018 05:57 AM

Hi Mårten

Thanks for getting back to me,

I appreciate the breakdown you have provided in your most recent comment, it really helps out!

I originally mistakenly believed that there was no package being deployed at all, which is what led me to mention that you would need to deploy a blank package in order to access the necessary features you required.

However, since you are already deploying a package, you can enable the Config Transformation feature as previously mentioned within the package step, in addition to enabling the Custom installation directory feature to specify the location of the config file that is not contained within the package currently being deployed.

I hope this helps!

Please let me know if you require any further assistance, I'd be more than willing to help :)

Kind Regards,

Reece

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

### »

#### Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

# Keyboard shortcuts

### Generic

? Show this help Blurs the current field

### Comment Form

r Focus the comment reply box Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

## Recent Discussions

 05 Dec, 2018 02:50 PM Octopus and Let's Encrypt with many sites 19 Nov, 2018 05:48 PM PowerShell Requirements 16 Nov, 2018 03:28 PM "Deploy a Release step" does not honour the Channel when selecting the release to use 12 Nov, 2018 04:24 PM Running a custom script using files in a package 15 Oct, 2018 11:32 AM Working around query timeouts?
 01 Oct, 2018 09:36 PM Azure Powershell Version Issue 26 Sep, 2018 12:48 PM Licenses - what is a machine? 26 Sep, 2018 09:42 AM Handling a tentacle reboot during a deployment 24 Sep, 2018 05:10 PM Octopus script Unable to locate the Extract location. 23 Aug, 2018 02:16 PM Tentacle cleanup when changing channels 23 Aug, 2018 08:08 AM "CreateProcess error=206, The filename or extension is too long" when running Octo.exe