How to Run PowerShell Script on Windows Startup?
How to Run PowerShell Script on Windows Startup?

This is useful when you want to run any automation created using PowerShell on Windows Startup. To run PowerShell script on startup.
Create a Windows Command Script (.cmd file) i.e. create a file and save it with .cmd
extension.

Write the below command in .cmd file.
powerShell path\to\powershell_script.ps1 >> “path\to\log_file.log”

If you want to run the script in background. Add -windowstyle hidden
after powershell.

Place the file or its shortcut file at below path.
C:\Users\<user_name>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

Restart the computer and you can track its execution in log file.
Another method is to create a ps1 file in startup and run your script.
Start-Process -WindowStyle Hidden C:\temp\Text.ps1
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.
Comments
Post a Comment