PowerShell Flashcards
The $ sign does what in variables?
Gets the contents of that variable. Also can be used to do things with the contents of the variable.
After executing break. What statements after the break cmd will be executed?
If, else if, and if statements
What does the global scope represent?
The entire shell
Whenever you run a script is a scope created for it?
Yes a separate on for the script
Do functions get their own scope too?
Yes they do
What is used to express relationships between scopes in powershell
Parent child type of relationship
If the value is being read and after going to global scope, and nothing is found what happens?
You get an error or a default value is used such as a empty string for variable $x
When you write a value, what scope does it take place in?
The current scope
When your done using a variable in a scope, does the same variable get destroyed in the other scopes? why?
No because the other scopes have their own copy and could have their own values.
When reading in a scope can you go down the path to child scopes?
No parent scopes aren’t allowed to do that.
Can each scope create elements with the same name as other scopes?
Yes it can for example aliases such as d in global and another d in script scope.
What is a best practice for scopes?
Let the scope be a wall, don’t start reaching into other ones, can make it very confusing.
What is another best practice?
Never access anything outside your own scope
best practice on undefined variable accessing?
Never access a variable that hasn’t been defined in your own scope yet
What should be used to pass info in and out of scopes?
A parameter to get info into the scope. And a write-output to pass info out of the scope