I have a script that contains a function that defines some variables within it for use later. For example, it looks like this:
$Rig = "TestRig1"
Function Setup{
If ($Rig -eq "TestRig1") {
$Script:Server="Alpharius"
$Script:IIS1="Tactical"
$Script:IIS2="Assault"
}
}
Setup
<do things with $Server>
(that's not the actual script, but it's similar)
What I'm curious about is if there's a better way to note this rather than individually labeling each variable with their scope. Is there some way I can state that all variables declared within a function are to be Script-scope?