PowerShell Flashcards

(55 cards)

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

What is PowerShell?

A

PowerShell is a task automation and configuration management framework from Microsoft.

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

True or False: PowerShell is only available on Windows operating systems.

A

False

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

What command is used to display the current directory in PowerShell?

A

Get-Location or the alias pwd

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

Fill in the blank: The command to list all files in the current directory is ____.

A

Get-ChildItem

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

What is the file extension for PowerShell scripts?

A

.ps1

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

Which cmdlet is used to create a new directory?

A

New-Item

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

True or False: PowerShell cmdlets are case-sensitive.

A

False

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

What is the purpose of the ‘Pipeline’ in PowerShell?

A

To pass the output of one cmdlet as input to another cmdlet.

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

Which cmdlet would you use to get help about another cmdlet?

A

Get-Help

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

What does the ‘Select-Object’ cmdlet do?

A

It selects specific properties of an object.

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

True or False: You can use PowerShell to manage Azure resources.

A

True

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

What is a PowerShell module?

A

A package that contains PowerShell cmdlets, functions, variables, and more.

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

What command is used to import a module in PowerShell?

A

Import-Module

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

Fill in the blank: The command to remove a file is ____.

A

Remove-Item alias rm

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

What does the ‘Get-Process’ cmdlet do?

A

It retrieves a list of processes running on a machine.

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

Which command would you use to stop a running process?

A

Stop-Process

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

What is the purpose of the ‘Set-ExecutionPolicy’ cmdlet?

A

To change the user preference for the PowerShell script execution policy.

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

True or False: PowerShell supports both imperative and declarative programming styles.

A

True

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

What is a PowerShell ‘Alias’?

A

A shortcut or an alternative name for a cmdlet.

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

Which cmdlet is used to clear the console screen?

A

Clear-Host

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

What does the ‘Get-Service’ cmdlet do?

A

It retrieves the status of services on a machine.

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

Fill in the blank: The command to start a service is ____.

A

Start-Service

24
Q

What is a PowerShell ‘Function’?

A

A block of code designed to perform a particular task.

25
What does the 'Write-Output' cmdlet do?
It sends output to the pipeline.
26
True or False: PowerShell can manipulate XML data.
True
27
What is the purpose of the 'Where-Object' cmdlet?
To filter objects based on specified criteria.
28
What is the command to display the contents of a file?
Get-Content
29
Fill in the blank: The command to rename an item is ____.
Rename-Item
30
What is a 'Hash Table' in PowerShell?
A data structure that stores key-value pairs.
31
Which cmdlet is used to export data to a CSV file?
Export-Csv
32
True or False: PowerShell can be used for web scraping.
True
33
What does the 'Invoke-WebRequest' cmdlet do?
It sends HTTP and HTTPS requests to a web page or web service.
34
What is the command to display all currently defined aliases?
Get-Alias
35
Fill in the blank: The command to update a module is ____.
Update-Module
36
What is the purpose of the 'ForEach-Object' cmdlet?
To perform an operation on each item in a collection.
37
What does the 'Start-Job' cmdlet do?
It starts a background job.
38
True or False: PowerShell supports remote management of computers.
True
39
What is the command to create a new PowerShell session?
New-PSSession
40
What cmdlet is used to retrieve the value of an environment variable?
Get-ChildItem Env:
41
Fill in the blank: The command to display system information is ____.
Get-ComputerInfo
42
What is the purpose of the 'Test-Connection' cmdlet?
To test the network connection to a computer.
43
What does the 'Get-EventLog' cmdlet do?
It retrieves entries from event logs.
44
True or False: PowerShell can be used to automate Microsoft Office applications.
True
45
What does the 'Get-Help' cmdlet provide?
It provides detailed information about cmdlets and concepts.
46
What is a PowerShell 'ScriptBlock'?
A collection of statements or expressions that can be executed as a single unit.
47
Which cmdlet is used to convert an object to JSON format?
ConvertTo-Json
48
Fill in the blank: The command to find the location of a cmdlet is ____.
Get-Command
49
What does the Get-Member cmdlet do in PowerShell?
Get-Member shows the properties and methods of an object, revealing what you can access or do with it. It helps explore object structure and capabilities.
50
What -parameter should you almost always specify after Format-Table to make the output easier to see?
Format-Table -AutoSize -AutoSize automatically adjusts column widths to fit the content better/easier to read.
51
How would you see all methods and properties of a service called Fucked?
Get-Service -name Fucked | gm or: Get-Service -Name Fucked | Get-Member GM is alias for Get-Member = gets all properties and methods of an object and is VERY VERY IMPORTANT to remember. Remember get-member gm.
52
What is the alias for Get-ChildItem in PowerShell?
Common aliases for Get-ChildItem are: gci ls dir They all do the same thing—list directory contents.
53
What does @() do in PowerShell?
@() defines an array @() in powershell E.g. $Var=@() $Var+="new stuff" $Var+="More stuff etc" $Var new stuff More stuff etc += adds new elements to the array. PS arrays are zero indexed so the first array item is [0]
54
What does this output in PowerShell? $numbers = @(1, 2, 3) $numbers[1]
2 Because arrays in PS are zero-indexed (start at [0]).
55
What is the syntax to add a new key-value pair to a PowerShell hashtable?
Add a key=value pair to a PS hash table: $hashtable["Key"] = "Value"