A script module is a PowerShell file (.psm1) that contains functions, variables, and code written in PowerShell script language. It is easy to create and edit using any text editor.
Click to reveal answer
beginner
What is a binary module in PowerShell?
A binary module is a compiled .NET assembly (.dll) that contains cmdlets and functions written in a .NET language like C#. It runs faster but requires compiling and development tools.
Click to reveal answer
beginner
Which module type is easier to create and modify: script or binary?
Script modules are easier to create and modify because they are plain text files written in PowerShell script. Binary modules require compiling code in a .NET language.
Click to reveal answer
intermediate
Why might you choose a binary module over a script module?
You might choose a binary module for better performance, access to .NET features, or to create complex cmdlets that are hard to write in script.
Click to reveal answer
beginner
How do you import a script module and a binary module in PowerShell?
Use Import-Module with the module name or path for both. PowerShell detects the type automatically and loads the module accordingly.
Click to reveal answer
What file extension does a PowerShell script module usually have?
A.ps1
B.dll
C.exe
D.psm1
✗ Incorrect
Script modules use the .psm1 extension, which contains PowerShell script code.
Which module type requires compiling code before use?
AScript module
BBinary module
CBoth
DNeither
✗ Incorrect
Binary modules are compiled .NET assemblies and require compiling before use.
Which module type is best for quick edits and simple functions?
AScript module
BNeither
CBinary module
DBoth equally
✗ Incorrect
Script modules are plain text and easy to edit quickly.
What command imports both script and binary modules in PowerShell?
AAdd-Module
BLoad-Module
CImport-Module
DGet-Module
✗ Incorrect
Import-Module loads both script and binary modules.
Why might a developer choose a binary module?
AFor better performance and .NET features
BTo write code faster
CBecause it is easier to edit
DBecause it uses plain text
✗ Incorrect
Binary modules offer better performance and access to .NET capabilities.
Explain the main differences between script modules and binary modules in PowerShell.
Think about file types, ease of editing, and performance.
You got /4 concepts.
When would you choose to use a script module instead of a binary module?
Consider speed of development and complexity.
You got /4 concepts.
Practice
(1/5)
1. Which statement best describes a PowerShell script module?
easy
A. It is a plain text file containing PowerShell functions and scripts.
B. It is a compiled DLL containing .NET cmdlets.
C. It requires Visual Studio to run.
D. It cannot be imported into a PowerShell session.
Solution
Step 1: Understand what a script module is
A script module is a .psm1 file that contains PowerShell code in plain text format.
Step 2: Compare with other module types
Binary modules are compiled DLLs, not plain text files, so they differ from script modules.
Final Answer:
It is a plain text file containing PowerShell functions and scripts. -> Option A
Quick Check:
Script module = plain text PowerShell code [OK]
Hint: Script modules are plain text files, binary are DLLs [OK]
Common Mistakes:
Confusing script modules with binary DLL modules
Thinking script modules require compilation
Assuming script modules cannot be imported
2. Which of the following is the correct way to import a script module named MyModule.psm1 in PowerShell?
easy
A. Import-Module MyModule.psm1
B. Import-Module MyModule.dll
C. Load-Module MyModule.psm1
D. Add-Module MyModule.psm1
Solution
Step 1: Identify the correct cmdlet for importing modules
PowerShell uses Import-Module to load both script and binary modules.
Step 2: Match the file extension with the module type
Script modules use .psm1 extension, so Import-Module MyModule.psm1 is correct syntax.
Final Answer:
Import-Module MyModule.psm1 -> Option A
Quick Check:
Import-Module + .psm1 file = correct [OK]
Hint: Use Import-Module with .psm1 for script modules [OK]
Common Mistakes:
Using Load-Module or Add-Module which don't exist
Trying to import .dll as script module
Omitting Import-Module cmdlet
3. Given the following PowerShell code, what will be the output?