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
Q

How do you get help for a given cmdlet

A

Get-Help [Cmdlet Name]

e.g. Get-Help Get-Command

26
Q

What is the typical structure of a Help entry?

A
NAME
SYNOPSIS
SYNTAX
DESCRIPTION
RELATED LINKS
REMARKS
27
Q

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

A

Get-Help [Command-Name] -online

28
Q

When working with a collection (in a pipelining scenario), how do you specify the “current” object?

A

$_

29
Q

What is the syntax for specifying all files with a length greater than 10kb?

A

Get-ChildItem | Where-Object{$_.Length -gt 10kb}

30
Q

How do we find out all Aliases on that have been imported?

A

Get-Alias

31
Q

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

A

Get-Alias [alias]

32
Q

How do we find which aliases exist for a given cmdlet?

A

Get-Alias -Definition [cmdlet-Name]

33
Q

Is it wise to use aliases in prod code?

A

No - people don’t necessarily know the aliases so best to use the full cmdlet name.

34
Q

What is pipelining?

A

A method in PowerShell by which we can chain cmdlets together.

35
Q

How do we set the current directory?

A

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

36
Q

What is the character that is used for pipelining?

A

The pipe “|”

37
Q

What is the filtering cmdlet for pipelining?

A

Where-Command

38
Q

In PowerShell, everything that you work with is an..

A

object

39
Q

When working with a collection (in a pipelining scenario), how do you specify the “current” object?

A

$_

40
Q

What is the syntax for specifying all files with a length greater than 10kb?

A

Get-ChildItem | Where-Object{$_.Length -gt 10kb}

41
Q

Back in Help, conceptual topics start with…

A

about_

42
Q

How do we get a list of conceptual topics

A

Get-Help about_*

43
Q

Which cmdlet do you use to sort a collection?

A

Sort-Object

44
Q

What is the syntax to retrieve a list of files whose length is greater than 10kb, sorted by length?

A

Get-ChildItem | Where-Object{$_.Length -gt 10kb} | Sort-Object Length

45
Q

How do you get details about the current version of PowerShell that is installed?

A

$PSVersionTable

46
Q

When pipelining how can you split the source code lines?

A

Make sure that the pipe character is the VERY LAST character on the line before starting a new line.

47
Q

Given the following:
Get-ChildItem |
Where-Object {$_.Length -gt 10kb} |
Sort-Object Length

How could you specify which properties to return?

A

Use Format-Table -Property [PropName1], [PropName2] etc

-AutoSize to automatically pad where necessary.

48
Q

Given Get-ChildItem how can we extract certain properties into a new object?

A

Get-ChildItem | Select-Object Name, Length

for example

49
Q

If we’re not using pipes, how can we split commands up over multiple lines?

A

Back-tick (`)

It HAS to be the last character (like the pipe)

50
Q

Get-ChildItem returns items from a ….

A

Provider

51
Q

How do you get the list of providers that are available?

A

Get-PSProvider

52
Q

How can a specific provider be specified when using Get-ChildItem

A

Specify the “drive” in the path. Eg:
Get-ChildItem env:
returns environment variables.

53
Q

Using pipelining, how can we pipe results into a gui Grid View?

A

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
Q

With the GridView how do we restrict / enable multiple selections?

A
  • OutputMode Single or

- OutputMode Multiple

55
Q

How can I specify a Title for the Grid View?

A

-Title “Title to display”

56
Q

How can I pass the selections from a GridView into a variable?

A

Use the -OutVariable parameter.
E.g.:
$ov = $null
Get-ChildItem | Out-GridView -PassThru -OutVariable $ov

57
Q

How do I clear the output screen

A

Clear-Host

58
Q

How do I get a list of drives (be they physical or provider-based)?

A

Get-PSDrive

59
Q

How can I set my own PS Drive?

A
Use Set-PSDrive
e.g.
New-PSDrive -Name cw `
            -PSProvider FileSystem `
            -Root C:\Users\chrisw
60
Q

How can I remove that PSDrive?

A

Remove-PSDrive [PSDriveName]