Calling a powershell script (Octopus Version 1.6.3.1723)

Hi,

I have written a powershell script ScriptsImport.ps1 that is part of my NuGet package.
This gets deployed on the destination machine. Once deployed, I want a step to call the powershell script.
I cannot seem to get it to call it. Receiving the following error:

2014-01-23 15:19:06 INFO ERROR: The term ‘.\ScriptsImport.ps1’ is not recognized as the name of a cmdlet, funct
2014-01-23 15:19:06 INFO ERROR: ion, script file, or operable program. Check the spelling of the name, or if a
2014-01-23 15:19:06 INFO ERROR: path was included, verify that the path is correct and try again.
2014-01-23 15:19:06 INFO ERROR: At C:\Users\Administrator\AppData\Local\Tentacle\Temp\2618ba8c-28c9-4059-b9f6-9
2014-01-23 15:19:06 INFO ERROR: 834d83cb937.ps1:1 char:2
2014-01-23 15:19:06 INFO ERROR: + . <<<< .\ScriptsImport.ps1
2014-01-23 15:19:06 INFO ERROR: + CategoryInfo : ObjectNotFound: (.\ScriptsImport.ps1:String) [],
2014-01-23 15:19:06 INFO ERROR: ParentContainsErrorRecordException
2014-01-23 15:19:06 INFO ERROR: + FullyQualifiedErrorId : CommandNotFoundException
2014-01-23 15:19:06 INFO ERROR:
2014-01-23 15:19:06 INFO ==============================================
2014-01-23 15:19:06 INFO PowerShell exit code: 0
2014-01-23 15:19:06 INFO ==============================================

Why am I trying to do this?
I have a single command line application that is used to manage the upgrades of 1000s of databases.
This is installed on each database server and manages the upgrades for that specific database server.
There is a specific order that upgrades must take place, i.e. a “master” database must be upgraded before each
of the customer databases. The console application manages this dependency (would be great if Octopus allowed us to define dependencies between steps). Essentially a different command line is called for each type of database that we need to upgrade.

Therefore in terms of deployment process

  1. Consolidated upgrade / regression scripts import to “upgrade management” repository takes place on a single box
  2. Next a powershell script is to run against a single box to upgrade the “master” database
  3. Next a powershell script is to run against all customer databases (if the master upgrade completed) on a whole host of boxes (determined by a role)

Hope this makes sense. I am not familiar with Powershell although I can confirm my scripts are working when run locally in the Powershell ISE (and to be honest don’t really want to have to be).

Example ps1 script contains the following contents:

$executableDirectory = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
$executableFilePath = Join-Path $executableDirectory “ForFront.eShot.ManagementUpgrade.Console.exe”
$commandLine = “$executableFilePath” + " -Mode UpgradeDatabases -DatabaseType ‘Customer’ -DatabaseVersion ‘6.0.5582.0’ -RunAgainst ‘.’ /Q"
Write-Host $commandLine
IEX “$commandLine”

Also bandwidth to the production environment from the offices is limited and we therefore want to separate out the deploying of the NuGet packages from their execution. So that we could upload nuget files hours before we are ready to publish the changes.

Hi Richard,

Subsequent steps in the process don’t share a working directory, so if you want a later script step to find the scripts deployed in an earlier package, the best way to do this would be to create a custom installation directory for the packages.

Cheers,
Nick

OK – Thank-you Nicholas.

I have managed to find a way to get around my issue whereby I have 1 powershell script with numerous variables that are replaced, each of which drives an if condition comparison.

Thanks again,

Regards,

Rik

Richard Beacroft
Tel (direct) +44 (0)20 3320 8755

http://www.e-shot.net/ e-shot.net Email Marketing

TO IMPROVE YOUR SALES AND CLIENT RETENTION
CALL OUR E-SHOT TEAM NOW ON 020 3320 8777
http://www.facebook.com/eshotEmailMarketing Facebook http://twitter.com/#/e_shot Twitter http://www.linkedin.com/company/e-shot?trk=fc_badge LinkedIn https://plus.google.com/#113229466455773591438/posts Google+

http://dma.org.uk/directory?display_name=e-shot we are a DMA membere-shot is a product of Forfront
Head office: Forfront.net, Renaissance House, 32 Upper High Street, Epsom, Surrey KT17 4QJ :: Tel +44 (0)20 3320 8750
Net Formation Ltd. t/a forfront.net is registered in England and Wales No. 3643637 at Russell Bedford House, City Forum, 250 City Road, London, EC1V 2QQ. VAT No. 702 8495 33. The information contained in this email and its attachments are confidential information and are intended for the named recipient(s) only. The unauthorised use, disclosure, copying or distribution of this e-mail or any of the information it contains is prohibited and may be unlawful. If you are not the intended recipient or if you receive this e-mail in error, please notify the sender immediately and delete the e-mail.


image005.jpg

image004.jpg

image003.jpg

image002.jpg

image001.gif

image006.gif