0
0
PowerShellscripting~10 mins

Module creation basics in PowerShell - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a new PowerShell module manifest.

PowerShell
New-ModuleManifest -Path "MyModule.psd1" -RootModule [1]
Drag options to blanks, or click blank then click option'
A"MyModule.psm1"
B"MyModule.psd1"
C"MyModule.psm"
D"MyModule.ps1"
Attempts:
3 left
💡 Hint
Common Mistakes
Using the manifest file (.psd1) as the root module file.
Using script files with incorrect extensions like .ps1 or .psm.
2fill in blank
medium

Complete the code to import a module named 'MyModule'.

PowerShell
Import-Module [1]
Drag options to blanks, or click blank then click option'
A"MyModule.psd1"
B"MyModule.ps1"
C"MyModule.psm1"
D"MyModule"
Attempts:
3 left
💡 Hint
Common Mistakes
Including the file extension when importing the module.
Using script files (.ps1) instead of module files.
3fill in blank
hard

Fix the error in the code to export the function 'Get-Info' from the module.

PowerShell
Export-ModuleMember -Function [1]
Drag options to blanks, or click blank then click option'
Aget-info
BGet-Info
CgetInfo
DGetInfo
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the dash between verb and noun.
Changing the case or spelling of the function name.
4fill in blank
hard

Fill both blanks to create a module file that defines a function and exports it.

PowerShell
function [1] { Write-Output "Hello" }
Export-ModuleMember -Function [2]
Drag options to blanks, or click blank then click option'
ASayHello
BGet-Data
Attempts:
3 left
💡 Hint
Common Mistakes
Using different function names in definition and export.
Forgetting to export the function.
5fill in blank
hard

Fill all three blanks to create a module manifest with version 1.0 and author 'Alice'.

PowerShell
New-ModuleManifest -Path "MyModule.psd1" -RootModule [1] -ModuleVersion [2] -Author [3]
Drag options to blanks, or click blank then click option'
A"MyModule.psm1"
B"1.0"
C"Alice"
D"MyModule.psd1"
Attempts:
3 left
💡 Hint
Common Mistakes
Using the manifest file as the root module.
Not quoting the version or author strings.