0
0
PowerShellscripting~20 mins

Why cross-platform extends reach in PowerShell - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Cross-Platform Scripting Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1: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?
ABecause scripts that run on multiple OSes can be used by more users regardless of their system.
BBecause cross-platform scripts run faster on all systems.
CBecause cross-platform scripts only work on Windows and Linux.
DBecause cross-platform scripts require less memory.
Attempts:
2 left
💡 Hint
Think about who can use the script if it works on many systems.
💻 Command Output
intermediate
1: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)"
ARunning on: Win32NT
BRunning on: Unix
CError: OSVersion.Platform not found
DRunning on: Win32NT or Unix depending on OS
Attempts:
2 left
💡 Hint
The script uses .NET to detect OS platform.
📝 Syntax
advanced
2:00remaining
Identify the correct cross-platform PowerShell syntax
Which option shows the correct way to write a cross-platform path in PowerShell?
A"/usr/local/bin"
B"C:\Users\Public"
CJoin-Path -Path $HOME -ChildPath "Documents"
D"C:/Users/Public"
Attempts:
2 left
💡 Hint
Use PowerShell cmdlets that adapt to OS path styles.
🔧 Debug
advanced
2: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 ```
AGet-ChildItem is not available on Linux.
BThe path uses Windows-style backslashes which Linux does not recognize.
CThe script lacks execution permissions on Linux.
DThe script uses a Windows-only cmdlet parameter.
Attempts:
2 left
💡 Hint
Check the path format for Linux compatibility.
🚀 Application
expert
2: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?
AGet-ChildItem "$HOME/Documents"
BGet-ChildItem "$env:USERPROFILE\Documents"
CGet-ChildItem "C:\Users\$env:USERNAME\Documents"
DGet-ChildItem "/Users/$env:USERNAME/Documents"
Attempts:
2 left
💡 Hint
Use environment variables that exist on all platforms.