Good Afternoon,

I am tasked with converting our batch files to Powershell and so far have been successful with our imaging scripts.  Now I am migrating to computer startup and logon scripts.

I have a script that needs to run when the computer boots up and I am setting the new powershell script under Computer Config\Admin Templates\Scripts\Startup under the PowerShell Scripts tab, scripts are set to run first.  The script is in the same location the old batch file was located.  

Scripts will be ran on Win 10 Ent at boot up.

After updating GPO on a couple test systems, the script does not seem to run, because the changes made are not being applied.  I can execute the script from an admin prompt with powershell -executionpolicy bypass myscript.ps1 and it runs fine and all changes are applied.

One, is there a way to catch any errors by redirecting output to a file?
Is there anything else we need to do or check?

Any help appreciated.

Thank You

0 Comments   [ - ] Hide Comments


Please log in to comment

Community Chosen Answer


Check out Start-Transcript

But as the automation guy that is writing the scripts... you really should be writing the logs yourself and trapping the errors. Its just bad practice if you are not trapping and dealing with errors.

I'd be careful porting scripts, as you'd just be porting (sometimes) junk across - there might be a new way to action what you require - its a chance to start a new so to speak.

Answered 04/21/2016 by: rileyz
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity



You might try using a . bat file to call PowerShell using the following command.

powershell -ExecutionPolicy Bypass -command "Computer Config\Admin Templates\Scripts\Startup\Logon_script.ps1"

Also, you may need to set "Configure Logon Script Delay". https://support.microsoft.com/en-us/kb/2895815

Answered 04/21/2016 by: gargoylemike
White Belt

Please log in to comment