PowerShell Quiz 4

0.0(0)
studied byStudied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/9

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 12:16 PM on 9/22/25
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

10 Terms

1
New cards

Conditions must be bounded by _____

()

2
New cards

What is wrong with the following statement?

if ($abc == "One")

  {Write-Host "They are equal"}

The == cannot be used as a conditional operator. You must use -eq

3
New cards

Play computer.  What is the first line printed by the code below?

$val = "Red"
$b=0
$r=0
$g=0
switch ($val)
  {
        "Blue" {
                $b++
                  Write-host "Violets are Blue"}
        "Green" {
                 $g++
                  Write-host "Leaves are green"}
        "Red" {
                 $r++
                 Write-host "Apples are red"}
  }
Write-host "B = $b    g = $g    R = $r"

Apples are red

4
New cards

What output would result from the following command?

$n = 3

if ($n -lt 5)

  { write-host $n}

3

5
New cards

What does the following code do?

if (test-connection -Computername "SRV1" -quiet -count 1 )

  {

       get-content -path \\SRV1\c$\config.txt

 }

If SRV1 is "pingable", it retrieves the contents of the specified file

6
New cards

Play Computer.  What will be printed by the code below?

for ($var = 0; $var -lt 3; $var++)

{  write-host $var }

0 1 2

7
New cards

Play Computer.  Step through the following program statements, keeping track of what is stored in memory and what is output.  Select the answer that correctly shows what is output following execution.

$grd = 75

$numpass = 0

$numfail = 0

if ($grd -lt 60)

     { numfail++ }

else

      {numpass++}

write-host "Number passing = $numpass, Number failing = $numfail"

Number passing = 1, Number failing = 0

8
New cards

Play Computer.  What will be printed by the code below?

$counter = 0 
 while ($counter -lt 5) 
   {    
              $counter    
              $counter++ 
           }

0 1 2 3 4

9
New cards

A condition must evaluate to be _______.

boolean ($true or $false)

10
New cards

Play Computer.  What will be printed by the statements below, assuming Cottonmouth and Diamond can be contacted, but Python can't.

$s = @("Cottonmouth", "Diamondback", "Python")
foreach ($i in $s)
{  
  if (test-connection -Computername $i -quiet -count 1)
    { write-host "$i is up"
    }
 else
   { write-host "$i is down"}
 }

Cottonmouth is up Diamondback is up Python is down

Explore top flashcards

AP Psych: Unit 0
Updated 529d ago
flashcards Flashcards (78)
BIOL 460 Exam 1
Updated 1111d ago
flashcards Flashcards (69)
Science exam
Updated 966d ago
flashcards Flashcards (167)
Vocab. 251-300
Updated 1013d ago
flashcards Flashcards (50)
ICT
Updated 1107d ago
flashcards Flashcards (55)
AP Psych: Unit 0
Updated 529d ago
flashcards Flashcards (78)
BIOL 460 Exam 1
Updated 1111d ago
flashcards Flashcards (69)
Science exam
Updated 966d ago
flashcards Flashcards (167)
Vocab. 251-300
Updated 1013d ago
flashcards Flashcards (50)
ICT
Updated 1107d ago
flashcards Flashcards (55)