This project is read-only.

execute ps script in post section with parameter

Topics: Archive - General
Mar 6, 2015 at 7:24 AM
Edited Mar 6, 2015 at 7:49 AM

how can I call a dot sourced powershell script with 3 arguments in the post section of Deploy-Application.ps1?

Deploy-Application.ps1 should proceed and not wait.




<Perform Post-Installation tasks here>

->  \\Share\Scripts\send.ps1 -arg1 -arg2 -arg3


thanks a lot

Mar 6, 2015 at 7:59 PM
Taking a hint from Set-ActiveSetup Function in AppDeployToolkitMain.ps1
    [string]$CUStubExePath = "$PSHOME\powershell.exe"
    [string]$CUArguments = "-ExecutionPolicy Bypass -NoProfile -NoLogo -WindowStyle Hidden -Command `"$StubExePath`""
    [string]$StubPath = "$CUStubExePath $CUArguments"
        If ($Arguments) {
            [string]$StubPath = "$StubPath $Arguments"
            If ($StubExeExt -ne '.exe') { [string]$CUArguments = "$CUArguments $Arguments" }
    $ExecuteResults = Execute-Process -FilePath $CUStubExePath -Arguments $CUArguments -PassThru
Means you probably should do it this way:
$MyArguments="\\Share\Scripts\send.ps1 -arg1 -arg2 -arg3"
$MyExecuteResults = Execute-Process -FilePath "$PSHOME\powershell.exe" -Arguments "-ExecutionPolicy Bypass -NoProfile -NoLogo -Command `"$MyArguments`" " -PassThru
This uses PSADT's Execute-Process function to do all the logging and error trapping in case your external file goes MIA or blows up.
Look for the Execute-Process function in AppDeployToolkitMain.ps1 for detailed help.

If this doesn't work you might need to switch the -Command to -File

Disclaimer: NOT TESTED
Mar 7, 2015 at 9:10 AM
it works well.

thanks a lot!