Use PowerShell to Create a Folder in Octopus Deploy

Octopus Deploy has a small but good selection of tasks that you can run as part of a deployment process. If you find yourself wanting to create a folder as part of a deployment (it could be a target for uploaded files, logs etc.) then you can do that quite easily through PowerShell.

In this example, we’ll create an App_Data folder.

1. Add a Step to Your Deployment Process

Add this step after you’re main deployment step.

2. Select ‘Run a PowerShell script’ as the step type

3. Fill out the step details

For our PowerShell script, we’ll use the New-Item command to create the directory.

Since we’re creating an App_Data folder directly under the site root, we can use the Octopus Deploy parameters to specify the location.

Our script looks like this:

-ItemType directory
-Path ($OctopusParameters['Octopus.Action[Deploy Website].Output.Package.InstallationDirectoryPath'] + 'App_Data')

Add this in to the step definition along with some description text:


Now, when your build runs, you’ll get a log of your new folder being created.