none
PowerShell GPO Startup Script Not Running - Windows 10

    Question

  • Hi All,

    I have added a GPO to run a simple PowerShell script on start-ups that uninstalls some of the unrequired Windows 10 apps.

    The 'ExecutionPolicy' is 'Unrestricted':

    It doesn't run in any form from what I can see.

    I know the script itself is fine as can be run manually.

    Please let me know if you need any other info to assist?

    Thanks in advance,

    Ben


    • Edited by Benny9997 Sunday, December 18, 2016 8:45 PM Clarification
    Sunday, December 18, 2016 8:41 PM

All replies

  • Hi Ben,
    Before we go further, please run gpresult /h command to view the group policy report if the GPO is applied successfully on the clients.
    If the GPO is not applying, you could check the following article for common reasons to try troubleshooting:
    10 Common Problems Causing Group Policy To Not Apply
    http://social.technet.microsoft.com/wiki/contents/articles/22457.10-common-problems-causing-group-policy-to-not-apply.aspx
    Here is an article below about how to assign computer startup script for your reference.
    Assign computer startup scripts
    https://technet.microsoft.com/en-us/library/cc770556(v=ws.11).aspx
    Please note: The path of script should be a NAC path so that other computer could access it.
    Best regards,
    Wendy

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Monday, December 19, 2016 3:24 AM
    Moderator
  • Hi Wendy,

    Thanks for replying.

    Running the gpresult /h shows that the GPO has been applied.

    Having had a look through the article (https://technet.microsoft.com/en-us/library/cc770556(v=ws.11).aspx) that is exactly how I have set this up.

    Do you have any other suggestions?

    Thanks in advance,

    Ben

    Monday, December 19, 2016 6:36 PM
  • Hi Ben,

    Could you find any event logs related to the problem?

    And please check if the computers have the permission to access the script. If the PowerShell scripts are located on a share instead of within the GPO, you will need to give computer the minimum Read permissions on both the share and NTFS of the script.

    In addition, you could have a try to use scheduled task for trigger the script at startup and see if it works.

    Best regards,

    Wendy


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Thursday, December 22, 2016 1:38 AM
    Moderator
  • Can you post the script contents? What's in it?

    Thursday, December 22, 2016 4:15 AM
  • Hi,

    I am checking how the issue going, if you still have any questions, please feel free to contact us.

    And if the replies as above are helpful, we would appreciate you to mark them as answers, and if you resolve it using your own solution, please share your experience and solution here. It will be greatly helpful to others who have the same question.

    Appreciate for your feedback.

    Best regards,

    Wendy


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Monday, December 26, 2016 7:49 AM
    Moderator
  • Hi Wendy,

    Apologies for the delayed response.

    The issue is still present. I can see no issues in the event log to advise what is causing this.

    I have also checked the permissions on the folder and the script both of which are set to allow everyone 'Read / Execute' permissions.

    I set the script as a GPO in a machine local GP and restarted and it ran so this is only present when it has to run the script has to run remotely over the domain.

    As requested by Narcoticoo, the script contains the following:

    Get-AppxPackage *bingsports* | Remove-AppxPackage
    Get-AppxPackage *xboxapp* | Remove-AppxPackage

    If you have any further suggestions please do let me know as this will be appreciated.

    Thanks,

    Ben

    Tuesday, December 27, 2016 11:04 PM
  • Hi,

    For a script to work, it might also need the SYSTEM user to be able to get to the script, have you checked the system user on the permission to access the script? And is there any other GPO or script stopping this one to be run?

    Best regards,

    Wendy


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Monday, January 2, 2017 1:45 AM
    Moderator
  • Hi Wendy,

    I have check and SYSTEM has access to all files for this.

    I have also attempted to call the Script from a BAT file and still it doesn't run. I do have another Start-up BAT that installs Office 2016 and this works fine.

    No other GPO is interfering as I have set this as the only one applied to the OU and it still fails to run.

    I am yet to get any PowerShell script to run on start-up so assume it must be isolated to this format as oppose to the specific script.

    Further support will be greatly received!

    Kind regards,

    Ben.

    Wednesday, January 4, 2017 5:48 PM
  • enabling deeper logging of the GPsvc may help your investigation about startup script execution?

    (this article is about diagnosing WMI but it details how to enable the deeper logging for GPsvc)

    https://support.microsoft.com/en-us/kb/2020286


    Don [doesn't work for MSFT, and they're probably glad about that ;]

    Thursday, January 5, 2017 1:50 AM
  • enabling deeper logging of the GPsvc may help your investigation about startup script execution?

    (this article is about diagnosing WMI but it details how to enable the deeper logging for GPsvc)

    https://support.microsoft.com/en-us/kb/2020286


    Don [doesn't work for MSFT, and they're probably glad about that ;]

    Thursday, January 5, 2017 1:50 AM
  • Also,

    For Windows Vista and later / WS2008 and later, Group Policy events are located in the Event Viewer, under \Applications and Services Logs\Microsoft\Windows\Group Policy\Operational


    Don [doesn't work for MSFT, and they're probably glad about that ;]

    Thursday, January 5, 2017 2:05 AM
  • Hi DonPick,

    Thanks for replying.

    I think it may be making an effort to run as the GPO Scripting process is in task manager for a short time. Looking in the EVENTVWR show nothing but information and non really relevant to the issue.

    Thanks on advance,

    Ben

    Saturday, January 7, 2017 10:49 PM
  • Hi DonPick,

    Checked that :).

    Thanks,

    Ben

    Saturday, January 7, 2017 10:49 PM
  • Hi,
    How is the issue going? if you still have any questions, please feel free to contact us.
    If you resolve it using your own solution, please share your experience and solution here. It will be greatly helpful to others who have the same question.
    Appreciate for your feedback.
    Best regards,
    Wendy

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Tuesday, January 10, 2017 1:56 AM
    Moderator
  • Wendy,

    Not sure why the previous comments were proposed as answers?

    Issue remains as per my reply.

    Ben

    Sunday, January 15, 2017 6:45 PM
  • Hold up,

    There is a feature - I believe - where if group policy is set, and you use a script to run that normally checks the execution policy it fails. This is a new thing in windows 10, where if policy sets the value it won't run. 

    Can you modify the script a little and apply it to a windows 7 machine to see if it works there?

    My organization encountered something similar recently and had to change it so that anything that uses windows 10 can't check or set the execution policy if Group Policy is already setting the value. 

    -J


    Please remember, if you see a post that helped you please click "Vote As Helpful" and if it answered your question, please click "Mark As Answer"

    Sunday, January 15, 2017 7:03 PM
  • I've countered the exact same issue in my organization, and after some experiments with adding logging to my script, I discovered something critical. The script runs correctly and executes all commands... However, Get-AppxPackage returns different results based on your user context.

    Try it. Run Get-AppxPackage as an administrator, then use Sysinternals tools to open a powershell as System instead, you'll get a different list of apps from Get-AppxPackage. I'm currently looking for a way to run the startup script in another context without exposing Admin rights.

    If anyone has any suggestions, please let me know.

    Friday, October 27, 2017 8:38 PM