What is the extension of PowerShell script files?
PS1
What are built in commands in the PowerShell known as?
cmdlets
I want to retrieve all services that have the word "windows" in them. How?
Get-Service -Name *windows*
$c = 100
$d = 200
$e = $c -gt $d
$e.GetType()
What is the type and value of the variable $e?
boolean
False
Which parameter does each cmdlet accept?
-Property
How would you get the date 45 days ago in powershell?
Get-Date.AddDays(-45)
What is the recommended syntax (structure) for PowerShell command.
Verb-Noun
Do something-To something
What is the alias of Get-ChildItem
dir
$colors = @("Orange","Yellow","Green","Blue","Indigo")
$colors.GetType()
What is the type of the $colors variable?
An array
What will Measure-Object do?
Counts # of objects in collection
What do PowerShell commands accept and return to the user?
PowerShell returns objects.
What is the PowerShell verb that is useful when you want information about something on your system?
Get
How would you get the properties and methods of a variable?
Get-Member or Tab completion
$var = @{Name = "Ian"; Age = 37; Height = 5.9}
$var.gettype()
What type is the $var variable?
What is the comparison operator for equal to?
-eq
What is the underlying technology that PowerShell is built on top of?
.NET
How can you use help to get examples about get-service?
get-help get-service -examples
What would you use to display the text to the user "Have a great Day"?
Write-Host
[int] $value = 100
$value = "Student"
Do the above commands work? Why?
No, $value is defined as an integer. A string cannot be assigned to the variable.
What (2) build-in variables are used to reference the object that was piped into the command?
$PSItem or $_
What operator makes an object recognized as a variable in powershell?
$
You want to get all commands that can control you DHCP server. What command would you use?
Get-Command –Noun *DHCP*
What does the following command do?
Get-Process | Where-Object {$_.WorkingSet -gt 20000000}
Return all processes, loop over them and select only the ones that have WorkingSet greater than the specified value.
$x = 100
$y = 200
Write-Host "`$x + `$y= " $x + $y
Write-Host "`$x + `$y= " ($x + $y)
What is the difference? What is the output?
$x + $y= 100 + 200
$x + $y= 300
() provide priority to do the math operation.
This comparison operator is incorrect
Wildcard equality = -we
Provide the correct one?
-like