Bird
Raised Fist0
PowerShellscripting~20 mins

PowerShell Gallery - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
PowerShell Gallery Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of listing installed modules?
You run the command Get-InstalledModule in PowerShell. What output do you expect if you have the module 'Pester' version 5.3.1 installed?
PowerShell
Get-InstalledModule
A
Name Version
---- -------
Pester 5.3.1
BPester 5.3.1
CNo output unless you specify -AllVersions
D
Name Version Repository
---- ------- ----------
Pester 5.3.1 PSGallery
Attempts:
2 left
💡 Hint
Think about the default properties shown by Get-InstalledModule.
💻 Command Output
intermediate
2:00remaining
What happens when you install a module twice?
You run Install-Module -Name Pester -Force twice in a row. What is the expected output or behavior?
PowerShell
Install-Module -Name Pester -Force
Install-Module -Name Pester -Force
AAn error occurs on the second command saying module already installed.
BThe module is installed once, second command overwrites without error.
CBoth commands install separate copies of the module side by side.
DThe second command prompts to confirm overwriting the module.
Attempts:
2 left
💡 Hint
The -Force parameter forces reinstallation without prompts or errors.
🚀 Application
advanced
2:00remaining
How to find the latest version of a module in PowerShell Gallery?
You want to find the latest available version of the module 'Pester' from the PowerShell Gallery without installing it. Which command will give you this information?
AFind-Module -Name Pester | Select-Object -Property Name, Version
BGet-InstalledModule -Name Pester | Select-Object -Property Name, Version
CInstall-Module -Name Pester -WhatIf
DSave-Module -Name Pester -Path .
Attempts:
2 left
💡 Hint
Find-Module searches the gallery without installing.
🔧 Debug
advanced
2:00remaining
Why does this Install-Module command fail with 'Access Denied'?
You run Install-Module -Name Pester in PowerShell and get an 'Access Denied' error. What is the most likely cause?
AThe module name 'Pester' is misspelled.
BPowerShell Gallery is offline or unreachable.
CYou are running PowerShell without administrator rights and trying to install to a system-wide location.
DYou have already installed the module.
Attempts:
2 left
💡 Hint
Installing modules system-wide requires admin rights.
🧠 Conceptual
expert
2:00remaining
What is the purpose of the PowerShell Gallery repository?
Which statement best describes the PowerShell Gallery repository?
AIt is an online repository where PowerShell modules and scripts are published and shared for easy discovery and installation.
BIt is a local folder on your computer where PowerShell stores installed modules.
CIt is a command-line tool to create PowerShell modules.
DIt is a security feature that blocks untrusted scripts from running.
Attempts:
2 left
💡 Hint
Think about where you get modules from when you use Install-Module.

Practice

(1/5)
1. What is the primary purpose of the PowerShell Gallery?
easy
A. To replace the PowerShell console with a graphical interface
B. To provide a free online repository for PowerShell scripts and modules
C. To act as a debugger for PowerShell scripts
D. To serve as a text editor for writing PowerShell scripts

Solution

  1. Step 1: Understand the role of PowerShell Gallery

    The PowerShell Gallery is known as a free online repository where users can find and share PowerShell scripts and modules.
  2. Step 2: Compare options with this role

    Options A, B, and C describe tools or features unrelated to the Gallery's main function.
  3. Final Answer:

    To provide a free online repository for PowerShell scripts and modules -> Option B
  4. Quick Check:

    PowerShell Gallery = Online script repository [OK]
Hint: Remember: Gallery = place to find and share scripts [OK]
Common Mistakes:
  • Confusing the Gallery with a script editor
  • Thinking it debugs scripts
  • Assuming it changes the PowerShell interface
2. Which PowerShell command is used to install a module from the PowerShell Gallery?
easy
A. Install-Module
B. Get-Module
C. Publish-Module
D. Remove-Module

Solution

  1. Step 1: Identify the command to install modules

    The command to install a module from the PowerShell Gallery is Install-Module.
  2. Step 2: Understand other commands

    Get-Module lists modules, Publish-Module uploads modules, and Remove-Module removes loaded modules, not installs.
  3. Final Answer:

    Install-Module -> Option A
  4. Quick Check:

    Install module = Install-Module [OK]
Hint: Install modules? Use Install-Module command [OK]
Common Mistakes:
  • Using Get-Module to install
  • Confusing Publish-Module with install
  • Trying Remove-Module to add modules
3. What will be the output of this command if the module 'PSReadLine' is already installed?
Install-Module -Name PSReadLine -Force
medium
A. The command will do nothing and return no output
B. An error saying module already exists
C. It will uninstall the existing module
D. The module will be installed again without prompt

Solution

  1. Step 1: Understand the -Force parameter

    The -Force parameter forces reinstallation even if the module exists.
  2. Step 2: Predict command behavior

    Because of -Force, the module will reinstall without asking for confirmation.
  3. Final Answer:

    The module will be installed again without prompt -> Option D
  4. Quick Check:

    -Force forces reinstall = The module will be installed again without prompt [OK]
Hint: Use -Force to reinstall without confirmation [OK]
Common Mistakes:
  • Assuming error if module exists
  • Thinking command does nothing silently
  • Confusing install with uninstall
4. You run Install-Module -Name MyModule but get an error: "Unable to find module MyModule in any repository." What is the likely cause?
medium
A. The command syntax is incorrect
B. You forgot to run PowerShell as administrator
C. The module name is misspelled or does not exist in the PowerShell Gallery
D. The module is already installed

Solution

  1. Step 1: Analyze the error message

    The error says the module cannot be found in any repository, meaning it likely does not exist or the name is wrong.
  2. Step 2: Check other options

    Running as administrator or syntax errors would give different errors. If module was installed, no 'not found' error occurs.
  3. Final Answer:

    The module name is misspelled or does not exist in the PowerShell Gallery -> Option C
  4. Quick Check:

    Module not found = name error or missing module [OK]
Hint: Check spelling and existence if module not found error appears [OK]
Common Mistakes:
  • Assuming admin rights cause this error
  • Thinking syntax is wrong
  • Believing module is installed despite error
5. You want to update all installed modules from the PowerShell Gallery to their latest versions. Which command should you use?
hard
A. Update-Module
B. Install-Module -Force
C. Get-Module -ListAvailable | Install-Module
D. Publish-Module -Force

Solution

  1. Step 1: Identify the command to update modules

    Update-Module is the correct command to update installed modules to the latest version from the Gallery.
  2. Step 2: Evaluate other options

    Install-Module -Force installs or reinstalls but does not update all modules automatically. Get-Module -ListAvailable | Install-Module is incorrect syntax and inefficient. Publish-Module uploads modules, not updates them.
  3. Final Answer:

    Update-Module -> Option A
  4. Quick Check:

    Update all modules = Update-Module [OK]
Hint: Use Update-Module to refresh all installed modules [OK]
Common Mistakes:
  • Using Install-Module to update all modules
  • Trying to pipe Get-Module to Install-Module incorrectly
  • Confusing Publish-Module with update
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard