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.
Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
Windows for business | Windows Server | User experience | PowerShell
{count} votes

2 answers

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

  2. MotoX80 37,151 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

Your answer

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