1 Reply Latest reply on Nov 20, 2015 6:11 AM by Bill Robinson

    wonderful powershell launcher

    Olivier Renault


      After loosing time on this problem (I am a unix administrator, not a windows admin), I share with you our powershell launcher.

      It is a pain to execute complex powershell commands with special caracters in command line.

      The simpliest way to do is

      1. copy your ps1 file (the powershell script) on the target (in c:\images in my example),

      2. copy the following launcher script named runliste_propriete_users.cmd on the target after having modifying the lines "set wd" and "set script"



      :: working directory of the script PS

      set wd=c:\images

      :: name of the script PS

      set script=lanceur.ps1

      :: Options (by default send to cmd in '-op1 value1 -opt2 value2'

      set options=%1


      :: launch of the PS

      pushd %wd%

      powershell -noprofile -command "&{$proc=(start-process powershell -PassThru -wait -WorkingDirectory %wd% -ArgumentList '-executionpolicy unrestricted -file %wd%\%script% %options%' -verb RunAs);exit $proc.exitcode}" && (

        echo Script %script% executed with succes


        exit 0

      ) || (

        echo Script %script% in error !!


        exit 1




      3. execute using the following type 1 script like that:


      nexec -e cmd /c "C:\\Images\\runliste_propriete_users.cmd"



      I hope it will help a lot of you, and save your precious time ;-)