Understanding the Powershell Platform Flashcards

1
Q

Name the two Powershell “flavors”

A

The “Command Window” and ISE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Name the two Powershell “flavors”

A

The “Command Window” and ISE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the methods to retrieve a directory listing?

A

dir
ls
Get-ChildItem

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

The best way to customize the command window or ISE is via the…

A

Shortcut to the relevant program. This means that the changes will be remembered.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Command Window is useful for

A

Calling Scripts

Exploratory Work

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

ISE is useful for

A

Development

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Powershell scripts have the extension

A

.ps1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Single line comments begin with a

A

#

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Multiline comments begin and end with

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Regions are denoted with

A
#region [Optional Title]
#endregion [Optional Title]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you retrieve a list of all system cmdlets?

A

Get-Command

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you retrieve a list of all system commands?

A

Get-Command

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do you retrieve a list of only cmdlets that have a noun of “Service”

A

Get-Command -noun “Service”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you get help for a given cmdlet

A

Get-Help [Cmdlet Name]

e.g. Get-Help Get-Command

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Command Window is useful for

A

Calling Scripts

Exploratory Work

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How do you see the online version of a help entry?

A

Get-Help [Command-Name] -online

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What’s the shortcut for pulling up help?

A

Command-Name -?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Single line comments begin with a

A

#

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Multiline comments begin and end with

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

How do we find which command a specific alias points to?

A

Get-Alias [alias]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

All commandlets (cmdlet) are structured as

A

Verb-Noun

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

How do you retrieve a list of all system cmdlets?

A

Get-Command

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

How do you retrieve a list of only cmdlets that have a verb of “Get-“

A

Get-Command -verb “Get”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

How do we set the current directory?

A

Set-Location “path\or\relative\path”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
How do you get help for a given cmdlet
Get-Help [Cmdlet Name] | e.g. Get-Help Get-Command
26
What is the typical structure of a Help entry?
``` NAME SYNOPSIS SYNTAX DESCRIPTION RELATED LINKS REMARKS ```
27
How do you see the online version of a help entry?
Get-Help [Command-Name] -online
28
When working with a collection (in a pipelining scenario), how do you specify the "current" object?
$_
29
What is the syntax for specifying all files with a length greater than 10kb?
Get-ChildItem | Where-Object{$_.Length -gt 10kb}
30
How do we find out all Aliases on that have been imported?
Get-Alias
31
How do we find which command a specific alias points to?
Get-Alias [alias]
32
How do we find which aliases exist for a given cmdlet?
Get-Alias -Definition [cmdlet-Name]
33
Is it wise to use aliases in prod code?
No - people don't necessarily know the aliases so best to use the full cmdlet name.
34
What is pipelining?
A method in PowerShell by which we can chain cmdlets together.
35
How do we set the current directory?
Set-Location "path\or\relative\path"
36
What is the character that is used for pipelining?
The pipe "|"
37
What is the filtering cmdlet for pipelining?
Where-Command
38
In PowerShell, everything that you work with is an..
object
39
When working with a collection (in a pipelining scenario), how do you specify the "current" object?
$_
40
What is the syntax for specifying all files with a length greater than 10kb?
Get-ChildItem | Where-Object{$_.Length -gt 10kb}
41
Back in Help, conceptual topics start with...
about_
42
How do we get a list of conceptual topics
Get-Help about_*
43
Which cmdlet do you use to sort a collection?
Sort-Object
44
What is the syntax to retrieve a list of files whose length is greater than 10kb, sorted by length?
Get-ChildItem | Where-Object{$_.Length -gt 10kb} | Sort-Object Length
45
How do you get details about the current version of PowerShell that is installed?
$PSVersionTable
46
When pipelining how can you split the source code lines?
Make sure that the pipe character is the VERY LAST character on the line before starting a new line.
47
Given the following: Get-ChildItem | Where-Object {$_.Length -gt 10kb} | Sort-Object Length How could you specify which properties to return?
Use Format-Table -Property [PropName1], [PropName2] etc | -AutoSize to automatically pad where necessary.
48
Given Get-ChildItem how can we extract certain properties into a new object?
Get-ChildItem | Select-Object Name, Length | for example
49
If we're not using pipes, how can we split commands up over multiple lines?
Back-tick (`) | It HAS to be the last character (like the pipe)
50
Get-ChildItem returns items from a ....
Provider
51
How do you get the list of providers that are available?
Get-PSProvider
52
How can a specific provider be specified when using Get-ChildItem
Specify the "drive" in the path. Eg: Get-ChildItem env: returns environment variables.
53
Using pipelining, how can we pipe results into a gui Grid View?
Out-GridView e.g. Get-ChildItem | Out-GridView Use -PassThrough switch to ensure that data is passed from the grid view through to the next cmdlet.
54
With the GridView how do we restrict / enable multiple selections?
- OutputMode Single or | - OutputMode Multiple
55
How can I specify a Title for the Grid View?
-Title "Title to display"
56
How can I pass the selections from a GridView into a variable?
Use the -OutVariable parameter. E.g.: $ov = $null Get-ChildItem | Out-GridView -PassThru -OutVariable $ov
57
How do I clear the output screen
Clear-Host
58
How do I get a list of drives (be they physical or provider-based)?
Get-PSDrive
59
How can I set my own PS Drive?
``` Use Set-PSDrive e.g. New-PSDrive -Name cw ` -PSProvider FileSystem ` -Root C:\Users\chrisw ```
60
How can I remove that PSDrive?
Remove-PSDrive [PSDriveName]