1

We currently have a PreDeploy.ps1, Deploy.ps1, PostDeploy.ps1 scripts specific to web applications or window services. Every once in a while we need to have an extension file to customize the deployment process.

We plan to implement extension files using an underscore - something like:

Deploy.ps1

    if( Test-Path "_Deploy.ps1" )
{
    $extensionFile = Resolve-Path "_Deploy.ps1"
    PowerShell -File $extensionFile 
}

How can i pass currently scoped variables (variable name and value) to the extensionFile?

1 Answer 1

2

Well don't start a new PowerShell instance. :-) Run the script in the current PowerShell instance e.g.:

& $extensionFile

If that $extensionFile needs to modify (or create) variables in the current scope then execute it like so:

. $extensionFile
1
  • I normally use & to execute external .exe programs and thought i would need powershell.exe - I'll give this a shot. Thanks! Oct 11, 2012 at 17:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.