Running powershell script in psadt

Im trying to run a powershell script with parameters in psadt and im running into the following error: ERROR Inner Expection(s)

Execute-Process -Path "$PSHOME\powershell.exe" -Parameters "file "$dirFiles\powershellscript.ps1""

but when I run it like this it works perfectly

Execute-Process -Path "$PSHOME\powershell.exe" -Parameters "file `"$dirFiles\powershellscript.ps1`""

what am I doing wrong here?

In the first line, the parameter is only "file "
The rest of the line is causing the error

The second line escapes the double quotes properly.

1 Like

Why not just load the script internally ?

. $dirFiles\powershellscript.ps1

You wouldn’t get the logging and error handling of PSADT

1 Like

Hello to all,

@That-Annoying-Guy Are you sure ? :slight_smile:

write-log -Message “Before”
. .\Files\test.ps1 # only has one line # write-log -Message “Inside my test.ps1”
write-log -Message “After”

( Copy from the log file )

[Installation] :: Before 1/1/1601 12:00:00 AM 0 (0x0000)
[Installation] :: Inside my test.ps1 1/1/1601 12:00:00 AM 0 (0x0000)
[Installation] :: After 1/1/1601 12:00:00 AM 0 (0x0000)

I did not check the error handling.

1 Like


By calling powershellscript.ps1 from inside Deploy-Application.ps1 it’s as if it was part of the Deploy-Application.ps1 script.

Messy but it makes sense.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.