PowerCLI

 View Only
  • 1.  Run powercli script from desktop shortcut

    Posted Jan 12, 2017 05:02 PM

    I am trying to create a desktop shortcut that launches a small .ps1 script how do i modify the default desktop shortcut so it launches the script?

    Thanks in advance



  • 2.  RE: Run powercli script from desktop shortcut

    Posted Jan 12, 2017 06:20 PM

    As a security measure you can't run a PowerShell script by double-clicking a .ps1 file.

    But you can create a desktop shortcut.

    Call powershell.exe and on the -File parameter point to your .ps1 file.

    Don't forget to load the PowerCLI modules and connect to a vSphere server in the .ps1 file.

    %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -File "C:\Scripts\MyFile.ps1"