PowerShell Flashcards

0
Q

The $ sign does what in variables?

A

Gets the contents of that variable. Also can be used to do things with the contents of the variable.

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

After executing break. What statements after the break cmd will be executed?

A

If, else if, and if statements

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

What does the global scope represent?

A

The entire shell

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

Whenever you run a script is a scope created for it?

A

Yes a separate on for the script

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

Do functions get their own scope too?

A

Yes they do

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

What is used to express relationships between scopes in powershell

A

Parent child type of relationship

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

If the value is being read and after going to global scope, and nothing is found what happens?

A

You get an error or a default value is used such as a empty string for variable $x

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

When you write a value, what scope does it take place in?

A

The current scope

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

When your done using a variable in a scope, does the same variable get destroyed in the other scopes? why?

A

No because the other scopes have their own copy and could have their own values.

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

When reading in a scope can you go down the path to child scopes?

A

No parent scopes aren’t allowed to do that.

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

Can each scope create elements with the same name as other scopes?

A

Yes it can for example aliases such as d in global and another d in script scope.

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

What is a best practice for scopes?

A

Let the scope be a wall, don’t start reaching into other ones, can make it very confusing.

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

What is another best practice?

A

Never access anything outside your own scope

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

best practice on undefined variable accessing?

A

Never access a variable that hasn’t been defined in your own scope yet

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

What should be used to pass info in and out of scopes?

A

A parameter to get info into the scope. And a write-output to pass info out of the scope

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

What does a cmdlet binding attribute do?

A

it changes your simple parametrized function into a advanced function. Some call it a script cmdlet.

16
Q

How does the parameter decorater go?

[Parameter()]

A

Goes on a per parameter basis

17
Q

If you have an array [] in your powershell script, and add a single item, will it fail?

A

No powershell will take that one item and make your array, an array of one item.

18
Q

What parameter description will accept input from pipeline?

A

ValueFromPipeline=$True

Of course you can probably go false but haha no reason to do that, probably don’t even let you do that.

19
Q

Any script or function that accepts input from the pipeline needs to have three named script blocks. What are they?

A

Begin{}
Process{}
End{}