Powershell script not running when applied through GPO. RRS feed

  • Question

  • Hi, I am applying a script to a workstation through GPO. The thing is that the script is not applying when I am deploying it through GPO, but I can deploy it when I am log in to workstation.

    Here is the script:

    Set-ExecutionPolicy Unrestricted
    # define store number for URL
    $wks = $env:computername
    $number = $wks.substring(3,3)
    # Create shortcut
    $Shell = New-Object -ComObject ("WScript.Shell")
    $ShortCut = $Shell.CreateShortcut($env:USERPROFILE + "\Desktop\Chrome.lnk")
    $ShortCut.TargetPath="C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
    $ShortCut.Arguments= "-kisok https://dom-prod/wsc/login.do?StoreId=SCXX$number"
    $ShortCut.WorkingDirectory = "C:\Program Files (x86)\Google\Chrome\Application\";

    Any ideas?

    • Edited by dbeslic Tuesday, August 8, 2017 7:35 PM
    • Moved by Bill_Stewart Friday, March 9, 2018 7:23 PM This is not GPO support forum
    Tuesday, August 8, 2017 7:34 PM

All replies

  • You cannot change the execution policy in a login script.  Change it with the PowerShell GPO. 

    PowerShell scripts are exempt from most execution policy restrictions.

    You need to use a GP Preferences Policy to create a shortcut.  DO not do it in a login script.

    Post in GP forum for help doing this with a GPO.


    Tuesday, August 8, 2017 7:44 PM
  • Hi. I can not use GP Preferences Policy because I need to have a script calculating URL specific for each workstation. I`ll post it in GP forum.

    Tuesday, August 8, 2017 8:47 PM
  • Creating a per-computer li k can be easily done by creating the link locally and copying to the remote system "Public Desktop" folder.  Just use Get-AdCOmputer to get a target list of systems.

    This only needs to be done once.

    A better method would be to allow the web site to use the computer name passed to the site to determine the final target. THis woul allow the use of GPP to create the link.


    • Edited by jrv Tuesday, August 8, 2017 8:51 PM
    Tuesday, August 8, 2017 8:51 PM
  • I have run gpresult and I can see that policy is being applied. The issue is that the script does not run wehn it is applied through GPO but it runs when it is applied directly on workstation. Here is an image:

    Also, I have to use a script because the script does calculation based on workstation name and gives URL that is added to shortcut.

    Wednesday, August 9, 2017 3:48 PM
  • Policy is set with the GPO Policy settings and no via GPP.



    Wednesday, August 9, 2017 3:50 PM