Calling another ps script from PreDeploy

segatarantinosegatarantino Posts: 3
edited May 8, 2014 3:11AM in Deployment Manager
Hello. Can you help me? I've a following text in my PreDeploy.ps1
$packScriptPath = "c:\lbs\Pack.ps1" 
$zipperPath = "C:\Program Files (x86)\7-Zip\7z.exe" 
if (my condition) 
    Invoke-Expression "&`"$packScriptPath`" -zipperPath `"$zipperPath`" -workPath `"$RedGatePackageDirectoryPath`"

When I executed this script from PS-window - it's Ok. But when I make deploy with Red Gate, PreDeploy.ps1 seems like not working - Pack.ps1 not executed

Maybe I can't use Invoke-Expression in Red Gate?
Help me, please.[/code]


  • You can use any valid PowerShell from Deployment Manager, so Invoke-Expression should work.

    Is it possible that the condition in:
    if (my condition)
    isn't evaluating to true when it's run in the context of the Deployment Agent? If you call some kind of output cmdlet (e.g. Write-Output) within the condition, does it execute?

    I'm also not sure why you're using Invoke-Expression at all here. I'd suggest the following (including a Write-Output call so you can see if the condition is true):
    if (my condition)
        Write-Output "Calling `"& $packScriptPath -zipperPath $zipperPath -workPath $RedGatePackageDirectoryPath`""
        & $packScriptPath -zipperPath $zipperPath -workPath $RedGatePackageDirectoryPath
    Development Lead
    Redgate Software
  • Yes. Problem was in condition (agent service permissions)
    Thanx! :)
Sign In or Register to comment.