Time to get back to the to blog. I've been working through my backlog of projects. These are things that I started writing or updating but then got pushed to the back of the line. One of these projects is a PowerShell module I wrote as a teaching tool. The idea was to create short quizzes on PowerShell topics that someone could take in a PowerShell session. My idea was to create quizzes on PowerShell topics, but you can create a quiz on anything. If you want to try things out, install the PSQuizMaster module from the PowerShell Gallery. The module will work in Windows PowerShell and PowerShell 7, including cross-platform.
ManageEngine ADManager Plus - Download Free Trial
Exclusive offer on ADManager Plus for US and UK regions. Claim now!
Take a Quiz
I've written a few sample quizzes that ship with the module. Use the Get-PSQuiz
command to display them,
The module defines a variable that indicates where you keep your quizzes. The default is the sample quiz folder.
PS C:\> $PSQuizPath
C:\Program Files\WindowsPowerShell\Modules\PSQuizMaster\1.0.0\quizzes
You most likely will want to create your own directory. You can run Set-PSQuizPath
to update the variable.
PS C:\> mkdir c:\quizzes
Directory: C:\
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 8/25/2023 5:39 AM quizzes
PS C:\> Set-PSQuizPath -Path c:\quizzes
PS C:\>
This will create a small JSON file under $HOME.
PS C:\> dir $home\.psquizsettings.json
Directory: C:\Users\artd
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 8/25/2023 5:39 AM 226 .psquizsettings.json
PS C:\> dir $home\.psquizsettings.json | get-content
{
"PSQuizPath": "c:\\quizzes",
"Updated": "8/25/2023 5:39:27 AM",
"Computername": "WIN10"
}
From now on, when you import the module, $PSQuizPath
will point to the folder you've specified. If you want, you can copy the sample quizzes to this new location.
PS C:\> Copy-PSSampleQuiz -Path C:\quizzes\
Directory: C:\quizzes
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 8/7/2023 2:47 PM 3206 Aliases.quiz.json
-a---- 8/6/2023 10:31 PM 6266 demo.quiz.json
-a---- 8/7/2023 2:47 PM 4032 pshelp.quiz.json
-a---- 8/7/2023 2:47 PM 4688 remoting.quiz.json
To take a quiz, run Invoke-PSQuiz
. You can tab-complete the quiz file.
Some quiz questions might have additional comments. At the end of the quiz is your grade.
Creating a Quiz
Quizzes are stored in JSON files.
{
"$schema": "https://raw.githubusercontent.com/jdhitsolutions/PSQuizMaster/main/psquiz.schema.json",
"metadata": {
"name": "PowerShell Aliases",
"author": "Jeff Hicks",
"description": "A short quiz on using aliases in PowerShell.",
"version": "0.2.3",
"id": "68d30b11-971e-4104-9d76-d862bcef6a37",
"updated": "2023-08-06 23:55:09Z"
},
"questions": [
{
"question": "What command will display currently defined PowerShell aliases?",
"answer": "Get-Alias",
"distractors": [
"Show-Alias",
"$PSAlias",
"Get-AliasDefinition",
"Find-PSAlias"
],
"note": ""
},
{
"question": "What PSDrive shows PowerShell aliases?",
"answer": "Alias",
"distractors": [
"A:",
"$Alias",
"psalias",
"$PSAliasDrive"
],
"note": "The drive name, does not include the colon (:)."
},
{
"question": "What command do you use to create a custom alias?",
"answer": "New-Alias",
"distractors": [
"Get-Alias",
"Add-Alias",
"New-PSDrive",
"Import-Alias"
],
"note": "You could use Import-Alias to recreate aliases exported with Export-Alias."
},
{
"question": "How can you protect an alias from being overwritten?",
"answer": "Set an option of ReadOnly or Constant",
"distractors": [
"You can't protect it",
"Set the scope to private",
"Set the scope to global"
],
"note": ""
}
]
}
I've created a JSON schema so you can create a quiz file directly in VS Code. The module has commands for creating a new quiz file and questions, but the best way is to run New-PSQuiz
and follow the prompts.
The answers in the quiz file are stored in plain text. I added an option to mask the answers.
Get-PSQuiz -Name *filtering* | Protect-PSQuizFile
The technique I use to mask the answers isn't complicated and easily undone.
It is aimed at deterring casual "cheaters."
I'm curious to learn how you use this module. One thought I had is that you could create a test for a user group meeting. Or you could use it for private, internal training classes.
PSQuickQuiz
The module also has a command called Invoke-PSQuickQuiz. This function will dynamically create a test based on PowerShell commands. The default is to use all modules on your computer. But you can exclude or specify a module.
Invoke-PSQuickQuiz -ModuleName Microsoft.Powershell.*
When finished, you'll get a grade.
I have a few other ideas to enhance this module, but I'd love to hear from you. You can visit the project's repository and post an issue or start a discussion.
Enjoy and have a great weekend.
It is a lucky coincidence. I wrote a script to improve one’s English speaking, or making some complex and meaningful sentences in English. The user is confronted a sentence in their native language; in my instance it is Turkish and challanged to think its English equivalent. I used hash table construct to present sentences randomly. It can be used for other languages simply replacing the first sentences in the hash table values.
The link is:
https://muratyildirimoglu.wordpress.com/2023/08/26/hem-ingilizce-calisalim-hem-de-hash-tablolarina-bir-goz-atalim/