I am currently encountered a problem with the Execute-ProcessAsUser function.
When I want to enter this command to get the exit code it doesn’t work, the script doesn’t run.
Execute-ProcessAsUser -Path “$PSHOME\powershell.exe” -Parameters “-Command & { & "C:\my path\Install_APPX.ps1
" -Install ‘APPX’ -Path C:\My APPX Path; Exit `$LastExitCode }” -Wait
However, when I enter this command, the command and my script is executed but if the path has spaces, it doesn’t work. (I see that in my script log)
Execute-ProcessAsUser -Path “$PSHOME\powershell.exe” -Parameters "-Command "C:\my path\Install_APPX.ps1
" -Install ‘APPX’ -Path C:\My APPX Path; Exit `$LastExitCode " -Wait
The purpose of this manipulation is to be able to install an appx in user context.
Thank for your help