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.
$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
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
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
Step: 1
The detailed answer for the above question is provided below Answer 1 an array of strings Answer 2 N...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started