Running PS over GP as admin

Marius Kulikauskas 21 Reputation points
2020-09-22T18:47:56.027+00:00

Hello,

I have a powershell script which installs network vpn settings and is working fine when it is run with admin priviledges on Windows 10.

However when I create Group Policy and add script to Computer Configuration -> Windows Settings -> Scripts -> PowerShell Scripts it would not install. I am guessing this could have something to do with running it as admin? I have verified via Rsop that GP does apply on the computer.

Windows for business | Windows Server | User experience | PowerShell
Windows for business | Windows Client for IT Pros | User experience | Other
{count} votes

4 answers

Sort by: Most helpful
  1. Vicky Wang 2,741 Reputation points
    2020-09-23T08:39:28.93+00:00

    Hi,@Marius Kulikauskas

    Any user configuration items, including login scripts are run with the user's permissions. In order to run a script (or software installation) with elevated permissions you need to either run it using Computer configuration, which will run as local system, or use group policy preferences to create a scheduled task and configure the desired credentials.
    I was able to make it work by putting the script inside the path (inside the GPO):

    Computer Configuration\Policies\Windows Settings\Scripts (Startup/Shutdown)

    In it, the script runs as administrator by the system, doing the installation.

    Hope this information can help you
    Best wishes
    Vicky

    0 comments No comments

  2. Vicky Wang 2,741 Reputation points
    2020-09-25T09:04:48.48+00:00

    Hi,
     
    Just want to confirm the current situations.
     
    Please feel free to let us know if you need further assistance.
     
    Best Regards,
    Vicky 

    0 comments No comments

  3. Marius Kulikauskas 21 Reputation points
    2020-09-29T14:45:07.993+00:00

    That is exactly what I did. Placed PS script under
    Computer Configuration\Policies\Windows Settings\Scripts (Startup/Shutdown)\PowerShell

    But it would not run. I tried also following with no luck
    Delay script
    Computer Configuration -> Administrative Templates -> System -> Group Policy section. Enable the “Configure Logon Script Delay”
    Turn on Script execution
    Administrative Templates -> Windows Components -> Windows PowerShell

    Not even sure where to look for logs why it failed to upload PS script..


  4. Vicky Wang 2,741 Reputation points
    2020-09-30T09:21:19.513+00:00

    Hi,
    Thank you for posting in our forum. According to your description, I feel that this problem is more likely to be a scripting problem. I recommend you to post to the scripting forum, they can give you more professional help
    Best wishes
    Vicky

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.