Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What does 'cross-platform' mean in scripting?
Cross-platform means a script or program can run on different operating systems like Windows, Linux, or macOS without changes.
Click to reveal answer
beginner
Why does cross-platform scripting extend reach?
Because it allows the same script to work on many devices and systems, reaching more users and environments easily.
Click to reveal answer
beginner
How does cross-platform scripting save time?
You write one script that works everywhere, so you don’t need to rewrite or maintain different versions for each system.
Click to reveal answer
beginner
Give an example of a cross-platform scripting language.
PowerShell is cross-platform because it runs on Windows, Linux, and macOS.
Click to reveal answer
beginner
What is a real-life benefit of cross-platform scripts?
Teams with different computers can use the same automation scripts, making collaboration easier and faster.
Click to reveal answer
What does cross-platform scripting allow you to do?
ARun scripts only on Windows
BWrite scripts that only work on one device
CRun scripts on multiple operating systems without changes
DMake scripts slower
✗ Incorrect
Cross-platform scripting means the same script runs on different systems like Windows, Linux, or macOS.
Why is cross-platform scripting good for teams?
ATeams can only use scripts on Windows
BTeams can share and use the same scripts on different computers
CTeams must rewrite scripts for each computer
DTeams need special software for each script
✗ Incorrect
Cross-platform scripts work on many systems, so teams don’t need different versions for each computer.
Which scripting language is known for being cross-platform?
APowerShell
BBatch scripting
CVBScript
DWindows CMD
✗ Incorrect
PowerShell runs on Windows, Linux, and macOS, making it cross-platform.
How does cross-platform scripting save time?
ABy using only Windows
BBy writing many scripts for each system
CBy avoiding automation
DBy writing one script that works everywhere
✗ Incorrect
One script for all systems means less rewriting and maintenance.
What is a key benefit of cross-platform scripts?
AThey reach more users and devices
BThey only work on one device
CThey require special hardware
DThey are harder to share
✗ Incorrect
Cross-platform scripts can run on many devices, increasing their reach.
Explain in your own words why cross-platform scripting extends reach.
Think about how one script can be used by many people on different computers.
You got /4 concepts.
Describe a real-life situation where cross-platform scripting is helpful.
Imagine a group working together but using Windows and Linux machines.
You got /4 concepts.
Practice
(1/5)
1. Why is writing cross-platform PowerShell scripts important?
easy
A. They only work on Windows systems
B. They can run on Windows, Linux, and macOS without changes
C. They require special hardware to run
D. They are slower than platform-specific scripts
Solution
Step 1: Understand cross-platform meaning
Cross-platform means the script runs on multiple operating systems like Windows, Linux, and macOS.
Step 2: Identify the benefit of cross-platform scripts
Scripts that run on many systems reach more users and environments without rewriting code.
Final Answer:
They can run on Windows, Linux, and macOS without changes -> Option B
Quick Check:
Cross-platform = Runs everywhere [OK]
Hint: Cross-platform means runs on many OS types [OK]
Common Mistakes:
Thinking cross-platform means Windows only
Assuming special hardware is needed
Believing cross-platform scripts are slower
2. Which PowerShell command syntax is correct for checking the OS platform in a cross-platform script?
easy
A. if ($env:OS -eq 'Linux') { Write-Host 'Linux' }
B. if ($PSVersionTable.OS -eq 'Windows') { Write-Host 'Windows' }
C. if ($PSVersionTable.Platform -eq 'Unix') { Write-Host 'Linux or macOS' }
D. if ($Platform -eq 'Unix') { Write-Host 'Unix' }
Solution
Step 1: Identify correct property for OS platform
$PSVersionTable.Platform is the standard way to check OS platform in PowerShell Core.
Step 2: Check syntax correctness
if ($PSVersionTable.Platform -eq 'Unix') { Write-Host 'Linux or macOS' } uses correct syntax and property. Others use invalid or non-existent properties.
Final Answer:
if ($PSVersionTable.Platform -eq 'Unix') { Write-Host 'Linux or macOS' } -> Option C
Quick Check:
Use $PSVersionTable.Platform for OS check [OK]
Hint: Use $PSVersionTable.Platform to detect OS [OK]
Common Mistakes:
Using $env:OS which is Windows-only
Referencing non-existent $PSVersionTable.OS
Using undefined variable $Platform
3. What will this PowerShell Core script output on a Linux system?
Step 1: Understand $PSVersionTable.Platform on Linux
On Linux, $PSVersionTable.Platform equals 'Unix'.
Step 2: Evaluate the if condition
The condition is true, so the script outputs 'Cross-platform script running'.
Final Answer:
Cross-platform script running -> Option A
Quick Check:
Linux means Platform='Unix' => Output A [OK]
Hint: On Linux, Platform is 'Unix' so if condition is true [OK]
Common Mistakes:
Assuming Platform is 'Linux' instead of 'Unix'
Expecting Windows output on Linux
Thinking script throws error
4. This script is intended to run on Windows and Linux but uses a Windows-only environment variable. What is the problem?
if ($env:OS -eq 'Windows_NT') { Write-Host 'Windows' } else { Write-Host 'Linux or macOS' }
medium
A. The else block syntax is incorrect
B. Missing parentheses around condition
C. Write-Host is not supported on Linux
D. Using $env:OS is Windows-only and undefined on Linux
Solution
Step 1: Check environment variable usage
$env:OS is defined only on Windows, so on Linux it is empty or undefined.
Step 2: Understand the problem with $env:OS
Because $env:OS is missing on Linux, the script relies on a Windows-specific variable, making it non-portable.
Final Answer:
Using $env:OS is Windows-only and undefined on Linux -> Option D
Quick Check:
$env:OS is Windows-only env var [OK]
Hint: Avoid Windows-only env vars for cross-platform scripts [OK]
Common Mistakes:
Thinking Write-Host is unsupported on Linux
Believing parentheses are required around if condition
Assuming else syntax is wrong
5. You want to write a PowerShell script that lists files differently on Windows and Linux but works on both. Which approach best extends your script's reach?
hard
A. Use $PSVersionTable.Platform to detect OS and run platform-specific commands
B. Use Windows-only cmdlets and expect errors on Linux
C. Write separate scripts for each OS and run manually
D. Ignore OS differences and run same commands everywhere
Solution
Step 1: Identify cross-platform detection method
Using $PSVersionTable.Platform lets the script detect OS at runtime.