Running a PowerShell Script when Machine boots

Gourav Kumar 1 Reputation point
2021-02-02T08:27:23.57+00:00

Hi All,

I want to run a PowerShell script when a machine (WVD) boots up.
I have used automation account for multiple things however I am missing the catch here that is "run the code when machine boots up".

Can someone please help me to achieve this.

As always thanks in advance :)

Regards,
Gourav

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,185 questions
Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,131 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,387 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Kasun Rajapakse 351 Reputation points
    2021-02-02T16:34:30.01+00:00
    1 person found this answer helpful.
    0 comments No comments

  2. MotoX80 32,076 Reputation points
    2021-02-02T17:34:54.827+00:00

    The classic approach would be to use the Task Scheduler and set a trigger for "At system startup". In the Actions tab set it to run Powershell.exe and in the Arguments field put the full path to the script that you want to run. On the General tab, specify the user that the script will run as, or just use System.

    63087-capture.jpg

    1 person found this answer helpful.
    0 comments No comments