Question: If you want to read a file line by line, you can use a blocklike this. $file = Get-Content data.txt $line = $null foreach ($line

If you want to read a file line by line, you can use a blocklike this.


  1. $file = Get-Content "data.txt"
    $line = $null

    foreach ($line in $file)
    {
    Write-Host $line
    }

    Note: The data.txt file contains some data.

    What data type the $line will be?

    A single element string

    an array of int[32] values

    Int[32] type

    an array of strings

Question 2

  1. Which of the following cmdlets will you use if you want to printall values produced inside a loop in one Write-Host and outputproduces into a single line.

    No-Line

    Skip-Line

    Drop-NewLine

    NoNewLine

question 3 Which statements below will produce the same result?if the

$temperature=100

if($temperature -le 0)

{

"Fuming Texas Summer"

}

elseif($temperature -le 32)

{

"Freezing"

}

elseif($temperature -le 50)

{

"Cold"

}

elseif($temperature -le 70)

{

"Cool and Nice"

}

else

{

"Hot"

}

if($temperature -le 0)

{

"Fuming Texas Summer"

}

elseif($temperature -ge 32)

{

"Freezing"

}

elseif($temperature -le 50)

{

"Cold"

}

elseif($temperature -le 70)

{

"Cool and Nice"

}

else

{

"Hot"

}

switch($temperature)

{

{ $_ -lt 32 } { "Below Freezing";break }

32 { "Exactly Freezing"; break }

{ $_ -le 50 } { "Cold"; break }

{ $_ -le 70 } { "Warm"; break }

default { "Hot"}

}

switch($temperature)

{

{ $_ -lt 32 } { "Below Freezing"; break}

32 { "Exactly Freezing"; break }

{ $_ -le 50 } { "Cold"; break }

{ $_ -ge 70 } { "Warm"; break }

default { "Hot"}

}

Question 4

  1. In the snippet below, the is expecting to print the result:

    This is a red apple

    $Data1='Apple'

    $Data2='Red'

    If ($Data1 XXXX 'Apple' YYYY $Data2 ZZZZ'Red') {

    'This is a red apple'

    }

    Select the operator combinations you would use for XXXX, YYYYand ZZZZ so it will not print the desired result.

    XXXX: -eq YYYY: == ZZZZ: -eq

    XXXX: -eq YYYY: -OR ZZZZ: -eq

    XXXX: -eq YYYY: -AND ZZZZ: -eq

    XXXX: -eq YYYY: -OR ZZZZ: -ge

Step by Step Solution

3.34 Rating (163 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The detailed answer for the above question is provided below Answer 1 an array of strings Answer 2 N... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!