/bundles/itninjaweb/img/Breadcrumb_cap_w.png
I would like to start a powershell script1 (change the name of the PC): 

1) before windows 10 boot ( preferable) or
2) at the first run (just once)

I prefer the first option but I couldn't find a way to do it. 

About the second option I have tried using a bach file with the commands below in startup folder:

PowerShell -Command "Set-ExecutionPolicy Unrestricted" >> "%TEMP%\StartupLog.txt" 2>&1 
PowerShell C:\Users\<user_name>\Desktop\script.ps1 >> "%TEMP%\StartupLog.txt" 2>&1
I located it in start 
C:\Users\admin\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
to execute the powershell file at the first start but it didn't work. If I run manually the powershell file works fine.

Thanks
1 Comment   [ - ] Hide Comment

Comments

  • Try the below command in a .bat file and have the .bat file in the start up location "C:\Users\admin\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"

    powershell.exe -ExecutionPolicy Bypass -File PATH_TO_POWERSHELL.ps1 -WindowStyle Hidden -NoProfile
Please log in to comment

There are no answers at this time
Answer this question or Comment on this question for clarity

Answers

Share