none
Powershell shutdown script issues RRS feed

  • Question

  • Hi Scripting Guys!

    I'm working on a project to optimize school computers in my region(mainly boot/startup time). As all the students are local administrators it often results in them installing various programs, programs that more often than not, is set as a start-up program, which obviously effects the start time.

    So i decided to make a powershell script to go in and edit the registry for startup programs, with the intent of making it a shutdown script to be applied through a group policy.

    But the script wont run.

    Trying to run it manually works fine.

    I've set execution policy to both all signed and remotesigned/unrestricted(i have signed the script though)

    I've disabled the UAC as it gave me some issues during testing

    I am a powershell rookie though so i'm sure i've missed some obvious mistake, either in the script or settings so i'm hoping you can assist me or point me in the right direction.

    The script looks something like this:

    Remove-Item -Path hklm:\Software\Microsoft\Windows\CurrentVersion\Run

    New-Item -Path hklm:\Software\Microsoft\Windows\CurrentVersion\Run\ -ItemType Key

    New-ItemProperty -Path hklm:\Software\Microsoft\Windows\CurrentVersion\Run\ -Value '"C:\Program Files\path to some driver.exe"  -PropertyType String -Name "name of some driver"

    bonus info:

    i'm testing in a virtual inviroment using a Win2008r2 Domain controller with Win7 clients

    From the clients, using rsop.msc, i can see the script, and the path, I can also see the attempt to start the script in eventviewer and it even says its finished about 2 seconds later. (rsop shows no last execution time)

    Kind regards

    Powershell rookie

    Thursday, March 19, 2015 12:38 PM

Answers

  • Well as i am a rookie at scripting i turned to you guys hoping to find out if i needed to add or change something in the script to make it work. But as it turns out, nothing had to be change.

    Apparently setting priority on powershells scripts to run first was the culprit, i assume this is simply due to the server, and /or clients wasn't updated.

    Changing it to undefined solved the problem.

    Thanks for all your answers though and have a great day!

    Friday, March 20, 2015 7:05 AM

All replies

  • Do not allow students to have administrator privileges, and then they cannot install software that affects the entire computer.

    -- Bill Stewart [Bill_Stewart]

    Thursday, March 19, 2015 12:51 PM
    Moderator
  • Hi Bill

    That would indeed be a simple solution however, due to various reason and implications this is not a possibility, which is part the reason why i turn to you guys looking for assistance

    Thursday, March 19, 2015 12:56 PM
  • In the end you will have disabled all first line security in your whole domain. Is that what you want to do?

    What kind of driver are you trying too install.  Many drivers are installed automatically by the system.


    ¯\_(ツ)_/¯

    Thursday, March 19, 2015 2:20 PM
  • Hi

    The purpose of the script is not to install any of the drivers but rather starting them up(or something like that) like start only essential drivers like the anti-virus software and mousepad drivers for laptops. So basically the script is supposed to delete the run folder in the registry database and then recreate it with only selected drivers.

    I hope i'm making sense?

    Regarding disabling all of first line security on my entire domain i'm not sure i follow? how will a shutdown script that edit the startup registry on my domain computers disable all that?

    Thanks


    Thursday, March 19, 2015 2:31 PM
  • Well that is just something that you do not want to do.  Take my  word for it.  It is unnecessary.  THe drivers will only run when needed.  You save nothing by this.  Also you cannot change drivers and things with the run key.

    Group Policy can manage this key yo keep it from being changed or to place certain things in it.


    ¯\_(ツ)_/¯

    Thursday, March 19, 2015 3:00 PM
  • That would indeed be a simple solution however, due to various reason and implications this is not a possibility

    Why is removing administrator permissions from students not a possibility? That is your first line of defense.

    This is a systems management problem, not a scripting question. You will not be able to solve your problems reliably using a script.


    -- Bill Stewart [Bill_Stewart]

    Thursday, March 19, 2015 4:00 PM
    Moderator
  • Well as i am a rookie at scripting i turned to you guys hoping to find out if i needed to add or change something in the script to make it work. But as it turns out, nothing had to be change.

    Apparently setting priority on powershells scripts to run first was the culprit, i assume this is simply due to the server, and /or clients wasn't updated.

    Changing it to undefined solved the problem.

    Thanks for all your answers though and have a great day!

    Friday, March 20, 2015 7:05 AM