/build/static/layout/Breadcrumb_cap_w.png

Computer Startup and Powershell Scripts

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   [ + ] Show comments

Answers (2)

Posted by: rileyz 8 years ago
Red Belt
1
Check out Start-Transcript
https://technet.microsoft.com/en-us/library/dd347721.aspx

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.

Posted by: gargoylemike 8 years ago
White Belt
0

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

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ