Automatically changing the Windows power plan

by Shijaz Abdulla on 04.05.2013 at 13:50

I use a Toshiba Dynadock u3.0 to connect my Windows 8 laptop to dual displays, printer, mouse & keyboard, webcam, etc and sometimes when I resume my computer from a Standby state, the displays do not work and I have to restart the computer.

One workaround is to unplug the Dynadock before you resume the computer from standby and re-plug it in once the computer has resumed.

An even better workaround is to create a custom power plan that does not cause the computer to go to standby when connected to AC power. However, if your computer is managed by an organization they might enforce a “preferred” power plan through group policy, which causes your custom power plan to be overridden, leaving you with the same problem.

Today we explore how we can create a custom power plan and create a simple scheduled task that will ensure your custom power plan remains enforced regardless of your organization’s enforced power plan. Bear in mind, that depending upon what privileges your administrator has provided you on your desktop, this method may or may not be effective.

1. Create a custom power plan that does not put your computer on standby. Set this as your current power plan. I’m calling my power plan Dynadock.

microsoftnow

2. Open the Command Prompt and type powercfg /list. Note the GUID of your Dynadock power scheme (highlighted below). You will need this in the next step.

3. Open Task Scheduler (you can search for it on the Start menu/screen. Look under Settings in Windows 8)

4. Click Create Task on the right pane.

5. Choose the options on each tab as follows

image

On the Triggers tab, click Newimage

image

On the Actions tab, click New

Action: Start a program

Program/script: C:\Windows\System32\powercfg.exe

Add arguments: /setactive <GUID>
(where GUID is the text you copied earlier in step 2)

image

Click OK

image

Review the other tabs and make changes if needed, the default settings should be ok.

Supply your username and password when prompted and you are all set!

What you have just done is creating a scheduled task that runs every hour to change your power scheme back to your own custom power plan, even if the system reverts back to the “preferred” plan.

Update (27-May-2013): If you use your Windows Domain account for the scheduled task, the job will stop running once your change your password. A simple way to fix this is to open Task Scheduler whenever you change your password and update the new password, or simply use a local account with admin privileges which will not be required to change password by group policies.

Adding a node on a SQL 2005 cluster

by Shijaz Abdulla on 18.09.2008 at 23:22

In the absence of a dedicated SQL DBA at the place where I work, I take care of the SQL Servers too. (No comment.)

One of the passive nodes of a SQL Server 2005 cluster had died a sudden death (hard drive and RAID failed under mysterious circumstances) which necessitated a total rebuild of the failed node.

So I went ahead and evicted passive node from the Cluster Administrator on the surviving active node. After the server rebuild was over, I configured Windows clustering on the second node using Cluster Administrator. Next, I started setup on the active node (from Control Panel –> Add/Remove Programs –> SQL Server 2005 –> Change).

I reached the point in the setup wizard where I choose to add a node to the existing virtual server/cluster. After a while I get the following error message:

Setup failed to start on the remote machine. Check the Task scheduler event log on the remote machine.

Upon checking the Task Scheduler event log on the node being rebuilt, I found this:

"SQL Server Remote Setup .job" (setup.exe) 9/18/2008 11:36:24 PM ** ERROR **
    Unable to start task.
    The specific error is:
    0x80070005: Access is denied.
    Try using the Task page Browse button to locate the application.

Now that’s very helpful, isn’t it?

A few minutes of head-scratching and web-searching yielded what I was missing – I was working on the servers connected via Remote Desktop! For the installation to start successfully on the remote (new) node, it should not have any active remote desktop sessions on it. I went ahead and closed all RDP sessions on the new node being rebuilt using Task Manager (Users tab) and also logged off the session that I was connected to.

Another retry from the first node, and setup now progressed without any errors.

Getting a list of scheduled tasks on all servers

by Shijaz Abdulla on 17.02.2008 at 11:26

There is a great script on Windows IT Pro that helps you get a list of all workstations/servers/domain controllers in a domain and then list the Scheduled Tasks that have been configured on these machines.

The script, written by Bill Stewart, can be downloaded from the Windows IT Pro website.

Essentially, this is how it can be put to use:

  1. To get a list of DC’s and dump it to a text file, type cscript enumcomputers.js /dc > dclist.txt
  2. Next, feed this list of DC’s to enumtasks.cmd and ask it to dump a list of scheduled tasks for each DC to another text file: enumtasks dclist.txt >dctasklist.txt
  3. Open dctasklist.txt in Notepad, any word processor or even Microsoft Excel.