Forum Discussion

SJamal85's avatar
SJamal85
Copper Contributor
Jul 07, 2022
Solved

Powershell script is not working using PSF

Hi Everyone,   I am trying to run a powershell script using the PSF binaries in a MSIX package. However, it is not working. The powershell script on its own is working as expected. Can someone look...
  • TIMOTHY_MANGAN's avatar
    TIMOTHY_MANGAN
    Jul 21, 2022
    1) The PsfScriptLauncher.ps1 file is missing from the root of the package. This file is part of the PSF. This file is required as it will be executed in PowerShell to then run your script.
    2) The timeout value in the Json is too low. The 10 represents 10ms which is generally not long enough for PowerShell to even start up. Increase to 10000 to get 10 seconds, for example.
    3) Add a sleep to the end of the powershell start-sleep 60 would give you time to see any error messages in the PowerShell window should they occur. If so, the timeout value will have to increase more.
    4) The Unrestricted option in the json will cause a problem if there is any GPO setting the PowerShell restriction policy. As is in your ps1 file, the Bypass option might be a better choice
    5) If you still have issues, use the Sysinternals DebugView tool which can display debugging information emitted by the PsfLauncher as it tries to start your script. Start that tool, then launch the shortcut.

Resources