How to deploy script run when startup

Trần Ngọc Nam 20 Reputation points
2023-05-04T04:27:09.7533333+00:00

Hi,

I want to configure to run script for all computers in domain when startup

I do it such as:

  • Create script and put it where all computers can access it
  • Create GPO: Script Startup

I tried enable GPO Turn on Script Execution with Allow all script, but it still doesn't work.

If I run script manual, it response like:User's image

Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,208 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,390 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. MotoX80 32,081 Reputation points
    2023-05-04T13:22:11.32+00:00

    What is the computer's execution policy? Run Get-ExecutionPolicy.

    Did you download this script from the internet? Look at the file properties and unblock the file if you see this.

    User's image

    0 comments No comments

  2. Limitless Technology 43,971 Reputation points
    2023-05-04T16:19:50.54+00:00

    Hello there,

    You can deploy the script as a Computer setting using Windows Settings > Scripts (Startup/Shutdown.

    These scripts will run in the system context and not the user. To limit this to only running once, you can add a little bit of logic in the script to check for the existence of the registry data.

    Create a GPO and execute the script in the system context during boot or shutdown (see "Computer setting > Windows Settings > Scripts (Startup/Shutdown)"). Startup/Shutdown scripts got the needed privileges.

    The Powershell executable provides a -ExecutionPolicy parameter allowing to bypass the global Execution Policy. This can be used in combination with -Command:

    Hope this resolves your Query !!

    --If the reply is helpful, please Upvote and Accept it as an answer–

    0 comments No comments