Deployment of Power Plan Settings

Sometimes you have a need to deploy multiple pre-configured power plans to your users. This guide explains how to deploy power plans with a pre-defined GUID and plan name for easy reference. We will cover how to export a power plan, import a power plan, set a name for a power plan and finally, how to script the import process in PowerShell.

Exporting an Existing Power Plan

Power plan changes in Windows can be manipulated through the included powercfg utility. To export a power plan, we first have to retrieve a list of available plans. To do this; open an administrative command prompt and issue the command below:

powercfg /list
Listing available power plans

After you have a list of power plans, copy the GUID for the plan that you would like to export. Issue the export command:

powercfg /export {FILEPATH} {GUID}
Exporting a power plan

Importing a Power Plan

To import a power plan, we can use the same powercfg utility. Ideally, we’d have the exported power plan file stored on a network share or inside a deployment package if you are scripting the installation with SCCM.

Issue the following command to import a power plan:

powercfg /import {FILEPATH} {GUID}

It is important to use a GUID on the end of the import command, as we can then programatically set a new name for the power plan later on. We can keep the same GUID that the plan had when we exported it.

Importing a power plan

After importing the power plan, you can see that the same name is set from when we exported the plan. We may however want to set a new name. This can be done via the following command:

powercfg /changename {GUID} {NEW_NAME}
Changing the power plan name

Finally, we’ll want to set the plan as active. You can see in the image above that the asterisk is next to the ‘Balanced’ power plan. This is the current active power plan. To set a new active plan, issue the following command:

 powercfg /setactive {GUID}
Seeing the active power plan

As you can see above, our new ‘Contoso Eco Power Plan’ is now the active plan for this system.

Importing a Power Plan via a script.

To enable a mass deployment of the power plan across the enterprise, creating and deploying a script is necessary. Below is a snippet of code for the import process. Ideally this script and the exported power plan would either be hosted on a network share or inserted into a deployment package for SCCM to deploy.

<#
.SYNOPSIS
  This script imports the a Power Plan

.DESCRIPTION
  

.INPUTS
  None

.OUTPUTS Log File
  

.NOTES
  Version:        1.0
  Author:         Chris Scott
  Creation Date:  20/03/2023
  Purpose/Change: 

.EXAMPLE
  PS C:\> .\Deploy-PowerPlan.ps1
#>

#----------------------------[Declarations]-----------------------------

$scriptVersion = '1.0'
$planGUID = "eb40421b-7b88-4ed1-8aa1-2f71d8b6a801"
$planLocation = "\\fileshare\resources\powerplans\custom_powerplan.pow"
$planName = "Contoso Eco Power Plan"

#-----------------------------[Execution]-------------------------------


#Import the power plan with a set GUID
powercfg -import $planLocation $planGUID

#Set the name of the power plan
powercfg -changename $planGUID $planName

#Set the imported power plan as the active power plan.
powercfg -setactive $planGUID
Posted in PowerShell | Tagged , , , | Leave a comment

Maze – Finding Student Contacts with a COVID Positive Case

We’re in the middle of summer here in Western Australia and we are starting to see the spread of COVID-19 in our community. It’s 2022 and we’ve been quite lucky to live a relatively good mostly lockdown-free life so far in this pandemic. The need has arisen to have an easy way to find which students have been situated in the same class as a confirmed case of COVID-19.

We currently use Maze from Civica Education as our Student Information System. Maze uses a MSSQL database to store its data, and has a reporting front end where reports can be easily produced and retrieved by end users.

The project started with crafting a SQL query to fetch the required data. This looked at various tables including: Staff, Students, Families, Timetable Quilt and Student Timetables. From here, we can deduce the lessons that particular individual had on that day, the other students in those lessons and the contact details for the families associated with those students. This helps to create a notification register for all affected.

In the end the query looks a like this:

SQL Query for Contact Data

This query returns the following fields:

  • Class code with the Staff Key appended. This is used to determine in Maze whether a new page should be printed with the alternate teacher. This is where the class might have a second teacher for one of the lessons.
  • Student Information: Name, Birthdate, Gender, Roll Group
  • Student Vaccination Status (This requires the Maze Covid Update which stores a Y OR N for double vaccination in the Students table).
  • Mothers Information: Name, Mobile, Address
  • Fathers Information: Name, Mobile, Address
  • Teachers Name
  • Students Name with the search day appended.

Now that the query was built, we can either use it like this in SQL or we can build a report in Maze for the end users. In Maze, we create query parameters as defined items, and from here we can reference them with [@{PARAM_NAME}] in the SQL query. Firstly, parameters for the student key, day and vaccination status were created. This look like the picture below:

Maze Report – Defined Items

Now that the parameters are created, the query needs to be modified slightly. In the Maze SQL Editor, remove the variables from the top of the query, then change @studentkey to [@studentkey], @daytocheck to [@query_day_raw] and finally @vaccination to [@vac_stat]. Maze requires square brackets to be placed around parameters for them to be used in the SQL query. Now the query will look like this:

Maze Report – Final SQL Query

Now that we have the data we need for the report, we need to create the format display for the report. In the report designer, we need two areas. One for the main data, and one that contains a page break. The page break area will contain a condition to only present when the CLASSIDENT key is different to the previous. This will result in a new page being printed for a different class. Once the fields are added to the report, the report designer will look like this:

Maze Report Designer – Detail 01 – Main Information

Finally we need to add some report logic to perform the page break and to keep track of the CLASSIDENT key. To achieve this we need to create another parameter in defined items called @CURR_CLASSIDENT in the report properties. This will be used to keep track of the current CLASSIDENT key and compare it to the next.

Once the parameter is added, an area needs to be created that just contains a page break. This page break area will only show when the @CURR_CLASSIDENT key changes.

Maze Report Designer – Detail 02 – Page Break

Finally, the report procedures are updated to set the @CURR_CLASSIDENT parameter to be the CLASSIDENT key.

Maze Area Properties – Detail 02 – Page Break Condition

That’s it! We now have a report to list all of the contacts a student has in a classroom with the family contact details for notification of a COVID-19 positive case. If you’d like to obtain a copy of the SQL query or the final Maze report, please don’t hesitate to contact me.

Posted in Databases, Maze Student Information System, SQL | Tagged | Comments Off on Maze – Finding Student Contacts with a COVID Positive Case