Challenge - 5 Problems
Cross-Platform Scripting Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate1:30remaining
Why does cross-platform scripting increase audience reach?
Which of the following best explains why writing scripts that run on multiple operating systems extends the reach of automation?
Attempts:
2 left
💡 Hint
Think about who can use the script if it works on many systems.
✗ Incorrect
Cross-platform scripts can be executed on different operating systems, so more users can use the automation without needing to rewrite it.
💻 Command Output
intermediate1:30remaining
Output of cross-platform PowerShell script
What is the output of this PowerShell script when run on both Windows and Linux?
PowerShell
Write-Output "Running on: $([System.Environment]::OSVersion.Platform)"Attempts:
2 left
💡 Hint
The script uses .NET to detect OS platform.
✗ Incorrect
The script outputs the platform name, which is 'Win32NT' on Windows and 'Unix' on Linux/macOS, so output varies by OS.
📝 Syntax
advanced2:00remaining
Identify the correct cross-platform PowerShell syntax
Which option shows the correct way to write a cross-platform path in PowerShell?
Attempts:
2 left
💡 Hint
Use PowerShell cmdlets that adapt to OS path styles.
✗ Incorrect
Join-Path automatically uses the correct path separator for the OS, making scripts portable.
🔧 Debug
advanced2:00remaining
Debugging cross-platform script error
This PowerShell script fails on Linux but works on Windows. What causes the error?
```powershell
Get-ChildItem C:\Windows\System32
```
Attempts:
2 left
💡 Hint
Check the path format for Linux compatibility.
✗ Incorrect
Linux does not recognize Windows-style paths with backslashes, causing the script to fail.
🚀 Application
expert2:30remaining
Creating a cross-platform script to list user files
You want a PowerShell script that lists all files in the current user's Documents folder on Windows, Linux, and macOS. Which script correctly achieves this?
Attempts:
2 left
💡 Hint
Use environment variables that exist on all platforms.
✗ Incorrect
The $HOME variable works on all platforms and points to the user's home directory, making the path cross-platform.