1/39
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Conditions must be bounded by _____
()
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
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
What output would result from the following command?
$n = 3
if ($n -lt 5)
{ write-host $n}
3
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
Play Computer. What will be printed by the code below?
for ($var = 0; $var -lt 3; $var++)
{ write-host $var }
0 1 2
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
Play Computer. What will be printed by the code below?
$counter = 0
while ($counter -lt 5)
{
$counter
$counter++
}
0 1 2 3 4
A condition must evaluate to be _______.
boolean ($true or $false)
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
The | character is called a ______________
pipe or pipeline
The PowerShell ISE is an acronym for
Integrated Script Environment
Which of the commands below illustrates the best way to invoke the script Script1 which resides in my current directory?
.\Script1
You can use an editor such as Word to create PowerShell Scripts.
False
____________________ is a process that matches each object you pass in to a command to parameters specified by the second command
Parameter binding
What happens when the following command is issued?
Get-Service -name "wuauserv" | Start-Service
the output of Get-service is piped into the start-service command, eliminating the need to specify parameters of what service to start
A ___________ is one or more commands, stored in a common file, that are executed individually when the file is executed.
script
What does the following command do?
command1 | more
the output of command1 is broken into multiple pages of output
PowerShell scripts must end with the extension ______.
.ps1
The PowerShell ISE allows you to enter a script and run or test it within the same application.
True
By default, the type of $n will be ___________.
$n = 123
Int32
Newbie Admin wants to store the value 0 in a variable. Which of the following statements would correctly solve the problem? (Select ALL correct answers)
A. tot = 0
B. $tot
C. $tot = 0
D. $n = 0
C & D
In PowerShell, what would be printed by the code below?
$num = 1
$num = 2.8
$fnum = [Int32]$num
$fnum
3
What are the basic data types?
boolean, string, integer and floating point
PowerShell uses Double by default for numbers with a decimal point.
True
What would be printed by the following code?
$Num = 80
$str = 'The Result is $Num'
$str
The Result is $Num
Newbie Admin is writing a PowerShell script and needs to determine the number of characters stored in the string variable $str. Which of the following would be a correct way to count the characters and store the result in the variable $num?
$num = $str.length
In the statements below, remove is a ________________
$Str = "A rolling stone gathers no moss."
$Str2 = $Str.remove(4,3)
method
What would be printed by the following code?
$Num = 80
$str = "The Result is $Num"
$str
The Result is 80
In the following scenario, what is stored in $Str2?
$Str = "A rolling stone gathers no moss."
$Str2 = $Str.remove(4,3)
A rong stone gathers no moss.
What command allows you to view help information on a command? (PowerShell command, not an alias)
get-help
When you are in PowerShell, commands are case-sensitive.
False
What command can be used to display all stored aliases?
Get-alias
Based on the image, If your current location is dir2, which statement below would move your location to dir3?
Set-Location ..\dir3
Based on the image, your current working directory is dir1. Which of the legacy DOS commands below would successfully change your directory location to dir3?
cd ..\dir3
Based on the image, Your current directory is dir1, which command below would successfully list the contents of dir2?
Get-Childitem ..\dir2
Based on the image, Your current location is dir3. Which of the statements below would successfully delete file3a.docx from dir3a?
remove-item dir3a\file3a.docx
Based on the image, If you are in dir1, what command would successfully remove all files in dir2?
remove-item ..\dir2\*.*
Dir is the alias for which PowerShell command?
Get-ChildItem
How do you run PowerShell in Administrator mode?
Access the PowerShell app, Right-click, then select "Run as Administrator"