Search code examples
powershellunc

Shortcut to ps1 file on unc path not working


Im trying to open a ps1 file that is in a UNC folder on the network using a shortcut. it works on a local c: drive with no spaces in the name The shortcut target is set to the below

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -windowstyle hidden \\share\info folder\somewhere else\thisfile.ps1

When i click it it doesn't open i have also tried without -windowstyle hidden and still no luck.

im sure i have missed something simple.


Solution

  • You have spaces in the path, you should encapsulate it with quotes and I think you need the -file switch (don't know the other ones you are using) :

    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -file "\\share\info folder\somewhere else\thisfile.ps1"