Maniman man
asked on
Automate powershell script when system boots
Hello Everyone,
I have the following powershell script:
(Get-Content C:/sample.txt -TotalCount 1) | Set-Content C:\sample.txt
I would like the above script to execute when system boot.
Can someone please advise the best option to do so?
Thank you
Manu
I have the following powershell script:
(Get-Content C:/sample.txt -TotalCount 1) | Set-Content C:\sample.txt
I would like the above script to execute when system boot.
Can someone please advise the best option to do so?
Thank you
Manu
ASKER
Hey thank you,
I have tried that unfortunately it did not work.
PowerShell -Command "Set-ExecutionPolicy Unrestricted" >> "%TEMP%\StartupLog.txt" 2>&1 PowerShell C:/sample.ps1>> "%TEMP%\StartupLog.txt" 2>&1
But did not work, maybe am missing something.
I have tried that unfortunately it did not work.
PowerShell -Command "Set-ExecutionPolicy Unrestricted" >> "%TEMP%\StartupLog.txt" 2>&1 PowerShell C:/sample.ps1>> "%TEMP%\StartupLog.txt" 2>&1
But did not work, maybe am missing something.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Looking at the previous answer, plus researching on other forums, I have found the best solution to answer my own question. I have just tested it in prod environment with sucess results.
Best Regards
Best Regards
This should give you some pointers:
http://stackoverflow.com/questions/20575257/how-to-run-powershell-script-when-computer-starts