locked
Hibernate all workstations idle for at least 30 minutes, after 10:00pm RRS feed

  • Question

  • Recently i came a across a challenge launched by my boss: Hibernate all workstations idle for at least 30 minutes, after 10:00pm.

    By GPO, i can. So, i wrote a script.

    I'm using a System.Runtime.InteropServices;

    I'm not good in scripts, for this i need help to improve it.

    Please, help me. Thank you.

    Saturday, April 4, 2015 1:22 AM

Answers

  • Recently i came a across a challenge launched by my boss: Hibernate all workstations idle for at least 30 minutes, after 10:00pm.

    By GPO, i can. So, i wrote a script.

    I'm using a System.Runtime.InteropServices;

    I'm not good in scripts, for this i need help to improve it.

    Please, help me. Thank you.

    You ask for help improving a script that you already wrote, but you don't provide said script, nor tell us which part of the script you're having difficulties with... This makes it a bit hard to help you...

    Still, I would not suggest going down the route of creating a script for this. Yes it can obviously be done, but there are mechanisms out there that are already more appropriate for handling such things which do not involve re-inventing the wheel: GPO and Scheduled Tasks are two of them.

    If you create it as a *pure* script with no "help" from outside applications, you need to consider these things:

    - How do I deploy the script to every machine?

    - The script will need to be running in the background the whole time, from the time the computer starts up until it shuts down (it will sit idly doing absolutely nothing until it's past 10:00, but it will be running in the background nonetheless).

    - How do you ensure it's running properly?

    - Who will support it going forward?

    If you use a GPO, you don't have to worry about any of those things (except about how to tell whether it's running properly).

    Alternatively, you could also create a scheduled task which kicks off at 10:00 daily with a condition of only start if computer is idle for over 30m where the command that it executes is to hibernate the computer. Scheduled tasks can also be created by GPO, so you don't have to worry about many of the things you would normally have to worry about if you were using a script.

    Again, don't try to re-invent the wheel unless there is some benefit to it. From what you told us about your requirements, there isn't in your particular case.

    • Proposed as answer by jrv Saturday, April 4, 2015 12:51 PM
    • Marked as answer by AleksSantos Monday, April 6, 2015 5:41 PM
    Saturday, April 4, 2015 12:31 PM
  • This blog post shows you how to set different power plans by time of day:

    Configuring a Power Plan with Group Policy Preferences (by Alan Burchill)

    • Marked as answer by AleksSantos Monday, April 6, 2015 5:41 PM
    Saturday, April 4, 2015 7:10 AM

All replies

  • This blog post shows you how to set different power plans by time of day:

    Configuring a Power Plan with Group Policy Preferences (by Alan Burchill)

    • Marked as answer by AleksSantos Monday, April 6, 2015 5:41 PM
    Saturday, April 4, 2015 7:10 AM
  • Recently i came a across a challenge launched by my boss: Hibernate all workstations idle for at least 30 minutes, after 10:00pm.

    By GPO, i can. So, i wrote a script.

    I'm using a System.Runtime.InteropServices;

    I'm not good in scripts, for this i need help to improve it.

    Please, help me. Thank you.

    You ask for help improving a script that you already wrote, but you don't provide said script, nor tell us which part of the script you're having difficulties with... This makes it a bit hard to help you...

    Still, I would not suggest going down the route of creating a script for this. Yes it can obviously be done, but there are mechanisms out there that are already more appropriate for handling such things which do not involve re-inventing the wheel: GPO and Scheduled Tasks are two of them.

    If you create it as a *pure* script with no "help" from outside applications, you need to consider these things:

    - How do I deploy the script to every machine?

    - The script will need to be running in the background the whole time, from the time the computer starts up until it shuts down (it will sit idly doing absolutely nothing until it's past 10:00, but it will be running in the background nonetheless).

    - How do you ensure it's running properly?

    - Who will support it going forward?

    If you use a GPO, you don't have to worry about any of those things (except about how to tell whether it's running properly).

    Alternatively, you could also create a scheduled task which kicks off at 10:00 daily with a condition of only start if computer is idle for over 30m where the command that it executes is to hibernate the computer. Scheduled tasks can also be created by GPO, so you don't have to worry about many of the things you would normally have to worry about if you were using a script.

    Again, don't try to re-invent the wheel unless there is some benefit to it. From what you told us about your requirements, there isn't in your particular case.

    • Proposed as answer by jrv Saturday, April 4, 2015 12:51 PM
    • Marked as answer by AleksSantos Monday, April 6, 2015 5:41 PM
    Saturday, April 4, 2015 12:31 PM
  • Claro, Fausto.. Eu desconhecia a funcionalidade de agendamento pelo GPO.
    Sinto até vergonha em assumir isso, mas na verdade é algo que nunca precisei implementar aqui.

    Agradeço sua ajuda e se quiser contribuir com mais alguma ideia, fique a vontade.

    Obrigado mais uma vez !!!!

    Monday, April 6, 2015 5:17 PM