A+ Scripting Basics Batch PowerShell and Bash Quiz

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Thames
T
Thames
Community Contributor
Quizzes Created: 12024 | Total Attempts: 174,522
| Attempts: 13 | Questions: 20 | Updated: Oct 29, 2026
Please wait...
Question 1 / 21
🏆 Rank #-- ▾
0 %
0/100
Score 0/100

1. Which PowerShell parameter allows you to run commands without confirmation?

Explanation

The -Force parameter makes many PowerShell cmdlets complete an action without prompting, such as overwriting read-only files or removing items that would normally require confirmation. Confirmation prompts can also be suppressed with -Confirm:$false. NoConfirm, Skip, and Auto are not standard PowerShell parameters, so they would cause an error rather than suppress prompts.

Submit
Please wait...
About This Quiz
A+ Scripting Basics Batch Powershell and Bash Quiz - Quiz

This quiz evaluates your understanding of scripting fundamentals in Windows and Linux environments. Master batch files, PowerShell, and Bash scripting\u2014essential skills for A+ CompTIA certification and IT operations. Learn to automate tasks, manage systems, and troubleshoot using command-line scripts across multiple platforms.

2.

What first name or nickname would you like us to use?

You may optionally provide this to label your report, leaderboard, or certificate.

2. Which PowerShell cmdlet stops a running service?

Explanation

Stop-Service stops a running Windows service by name, for example Stop-Service -Name Spooler to stop the Print Spooler. Its counterparts Start-Service and Restart-Service handle starting and restarting. Stopping a service may require an elevated PowerShell session with administrator rights. Stop-Process ends a running process rather than a service, and Halt-Service and End-Service are not valid PowerShell cmdlets.

Submit

3. In batch scripts, how do you create a comment?

Explanation

In batch scripts, comments start with REM, short for remark, and any text after it on that line is ignored. Many scripts also use a double colon (::) as an informal comment. The # symbol marks comments in PowerShell and Bash, // is used in languages like C and JavaScript, and -- is used in SQL.

Submit

4. True or False: A Bash script typically begins with a shebang line, such as #!/bin/bash, that tells the system which interpreter should run it.

Explanation

The statement is true. The shebang line, written as #! followed by an interpreter path such as /bin/bash, must be the first line of the script. It tells the system which program should run the file when it is executed directly, for example with ./backup.sh, after execute permission has been granted with chmod.

Submit

5. In PowerShell, which operator is used for logical AND?

Explanation

PowerShell uses word-based comparison and logical operators that begin with a hyphen, so logical AND is written as -and, as in if ($a -gt 5 -and $b -lt 10). Similarly, -or and -not handle other logic. In PowerShell 7, && and || only chain commands based on success, and & is the call operator.

Submit

6. What does the setlocal command do in batch scripts?

Explanation

The setlocal command starts a local scope for environment variables in a batch script, so any variables created or changed afterward are discarded when the script ends or reaches endlocal. This keeps scripts from leaving stray variables in the user’s session. It does not change time zones, language settings, or create backups.

Submit

7. In Bash, which test operator checks whether a path exists, regardless of whether it is a file or a directory?

Explanation

In Bash test expressions, -e checks whether a file or directory exists, as in if [ -e /etc/hosts ]. The other options test more specific conditions: -f checks for a regular file, -d checks for a directory, and -x checks whether the file is executable. Each of them returns false if the path doesn’t exist.

Submit

8. Which PowerShell cmdlet retrieves help information for a command?

Explanation

Get-Help displays documentation for any cmdlet, including its syntax, parameters, and description. Adding -Examples shows sample usage, and -Online opens the full documentation in a browser. Running Update-Help downloads the latest help files. Show-Help, Find-Help, and Help-Command are not real cmdlets, though help works as a built-in shortcut for Get-Help.

Submit

9. True or False: Variables in batch scripts must be enclosed in curly braces.

Explanation

The statement is false. Batch scripts reference variables by surrounding the name with percent signs, as in %username% or %path%, and set values with the set command, such as set name=value. Curly braces are used in other languages, including PowerShell script blocks and Bash variable expansion like ${name}, but not for batch variables.

Submit

10. In Bash, the chmod command modifies what file attribute?

Explanation

The chmod command changes a file’s permissions, controlling who can read, write, or execute it. For example, chmod +x script.sh makes a script executable, and chmod 755 sets permissions using numeric notation. Ownership is changed with chown, file names with mv, and size changes only when the file’s contents change.

Submit

11. Which scripting language is native to Windows and uses .bat or .cmd file extensions?

Explanation

Batch is the native Windows command-line scripting language, saved with .bat or .cmd extensions and run by the cmd.exe interpreter. It has been part of Windows since the MS-DOS era. PowerShell scripts use .ps1, Bash scripts commonly use .sh on Linux and macOS, and Python scripts use .py and require a separately installed interpreter.

Submit

12. In batch scripts, what does the @echo off command do?

Explanation

Placing @echo off at the top of a batch file stops each command from being displayed in the console as it runs, so users see only the script’s intended output. The echo off part hides later commands, and the @ symbol hides that line itself. It does not stop the script, suppress errors, or delete files.

Submit

13. True or False: A batch script will run correctly in PowerShell if you simply rename it from .bat to .ps1.

Explanation

The statement is false. PowerShell uses different syntax from batch, including $ for variables instead of %var%, different comment markers, and cmdlets instead of many batch commands, so a renamed batch file usually fails. PowerShell can still launch existing .bat files directly, which lets organizations keep older scripts while migrating to PowerShell.

Submit

14. Which symbol redirects standard output to a file, overwriting any existing content, in both batch and Bash?

Explanation

The single greater-than symbol (>) redirects standard output to a file in both batch and Bash, creating the file or overwriting its existing contents, as in dir > list.txt. The double symbol (>>) appends output to the end of the file instead. The pipe passes output to another command, and < redirects input from a file.

Submit

15. In Bash, what does the grep command do?

Explanation

The grep command searches files or command output for lines matching a text pattern or regular expression, such as grep error /var/log/syslog. Options like -i ignore case and -r search directories recursively. Grouping by size is not its job, compression uses tools like gzip or tar, and tree displays directory structure.

Submit

16. Which PowerShell cmdlet is used to retrieve a list of running processes?

Explanation

Get-Process returns a list of processes running on the computer, including names, IDs, and CPU and memory usage, similar to the Processes tab in Task Manager. Get-Service lists Windows services rather than processes. Get-Task and List-Processes are not real cmdlets, even though their names resemble the Verb-Noun format genuine cmdlets use.

Submit

17. What does the pipe (|) operator do in PowerShell and Bash?

Explanation

The pipe operator sends the output of one command directly into another as input, letting commands be chained together. For example, Get-Process | Sort-Object CPU sorts processes in PowerShell, and ls | grep log filters a listing in Bash. It does not create files, compare files, or redirect only errors.

Submit

18. In batch scripts, which command echoes text to the console?

Explanation

The echo command displays text in the console, for example echo Backup complete, and is one of the most common batch commands. It is also used as echo off to control command display. Print sends files to a printer in Windows, while write and display are not valid batch commands for console output.

Submit

19. Which of the following is the correct syntax for a for loop in Bash?

Explanation

Bash supports a C-style for loop using double parentheses, written as for (( i=0; i < 10; i++ )), followed by do and done. The $i syntax is PowerShell, for i = 1 to 10 is BASIC or VBScript style, and a brace-expansion loop such as for i in {1..10} needs a semicolon or newline before do.

Submit

20. In PowerShell, what symbol is used to denote a variable?

Explanation

PowerShell variables always begin with a dollar sign, such as $name or $count, and the same symbol is used when assigning and reading values. Batch scripts use percent signs around variable names, as in %name%. The ampersand runs commands in PowerShell, and the at sign is used for arrays, hash tables, and splatting.

Submit
×
Saved
Thank you for your feedback!
View My Results
Cancel
  • All
    All (20)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Which PowerShell parameter allows you to run commands without...
Which PowerShell cmdlet stops a running service?
In batch scripts, how do you create a comment?
True or False: A Bash script typically begins with a shebang line,...
In PowerShell, which operator is used for logical AND?
What does the setlocal command do in batch scripts?
In Bash, which test operator checks whether a path exists, regardless...
Which PowerShell cmdlet retrieves help information for a command?
True or False: Variables in batch scripts must be enclosed in curly...
In Bash, the chmod command modifies what file attribute?
Which scripting language is native to Windows and uses .bat or .cmd...
In batch scripts, what does the @echo off command do?
True or False: A batch script will run correctly in PowerShell if you...
Which symbol redirects standard output to a file, overwriting any...
In Bash, what does the grep command do?
Which PowerShell cmdlet is used to retrieve a list of running...
What does the pipe (|) operator do in PowerShell and Bash?
In batch scripts, which command echoes text to the console?
Which of the following is the correct syntax for a for loop in Bash?
In PowerShell, what symbol is used to denote a variable?
play-Mute sad happy unanswered_answer up-hover down-hover success oval cancel Check box square blue
Alert!