Today's tip ‣ Lexical structure: Real literals
”A real literal may contain a numeric-multiplier (kb, mb, gb, tb, pb).”
#tip
”A real literal may contain a numeric-multiplier (kb, mb, gb, tb, pb).”
#tip
👍1
Today's tip ‣ Basic concepts: Error handling
”An error falls into one of two categories. Either it terminates the operation (a terminating error) or it doesn't (a non-terminating error). With a terminating error, the error is recorded and the operation stops. With a non-terminating error, the error is recorded and the operation continues.”
#tip
”An error falls into one of two categories. Either it terminates the operation (a terminating error) or it doesn't (a non-terminating error). With a terminating error, the error is recorded and the operation stops. With a non-terminating error, the error is recorded and the operation continues.”
#tip
Today's tip ‣ Basic concepts: Scopes
”Unless dot source notation is used, each of the following creates a new scope:
- A script file
- A script block
- A function or filter”
#tip
”Unless dot source notation is used, each of the following creates a new scope:
- A script file
- A script block
- A function or filter”
#tip
Today's tip ‣ Types: Value types
”The switch type is used to constrain the type of a parameter in a command. If an argument having the corresponding parameter name is present the parameter tests $true; otherwise, it tests `$false`. In PowerShell, `switch` maps to `System.Management.Automation.SwitchParameter`.”
#tip
”The switch type is used to constrain the type of a parameter in a command. If an argument having the corresponding parameter name is present the parameter tests $true; otherwise, it tests `$false`. In PowerShell, `switch` maps to `System.Management.Automation.SwitchParameter`.”
#tip
Today's tip ‣ Arrays: Arrays as reference types
”As array types are reference types, a variable designating an array can be made to refer to any array of any rank, length, and element type.”
#tip
”As array types are reference types, a variable designating an array can be made to refer to any array of any rank, length, and element type.”
$a = 10,20 # $a refers to an array of length 2
$a = 10,20,30 # $a refers to a different array, of length 3
$a = "red",10.6 # $a refers to a different array, of length 2
$a = New-Object 'int[,]' 2,3 # $a refers to an array of rank 2
#tip
Today's tip ‣ Lexical structure: Variables
”Variables can also be defined by the cmdlet New-Variable.”
#tip
”Variables can also be defined by the cmdlet New-Variable.”
#tip
Today's tip ‣ Lexical structure: Line terminators
”A line terminator (CR, LF, CR\LF) can be treated as white space.”
#tip
”A line terminator (CR, LF, CR\LF) can be treated as white space.”
#tip
👍1
Today's tip ‣ Types: Common
”The void type cannot be instantiated. It provides a means to discard a value explicitly using the cast operator [].”
#tip
”The void type cannot be instantiated. It provides a means to discard a value explicitly using the cast operator [].”
#tip
Today's tip ‣ Basic concepts: Environment variables
”The PowerShell environment provider allows operating system environment variables to be retrieved, added, changed, cleared, and deleted.”
#tip
”The PowerShell environment provider allows operating system environment variables to be retrieved, added, changed, cleared, and deleted.”
#tip
👍1
Today's tip ‣ Lexical structure: Multiplier suffixes
”For convenience, integer and real literals can contain a numeric-multiplier, which indicates one of a set of commonly used powers of 10. numeric-multiplier can be written in any combination of upper- or lowercase letters.”
#tip
”For convenience, integer and real literals can contain a numeric-multiplier, which indicates one of a set of commonly used powers of 10. numeric-multiplier can be written in any combination of upper- or lowercase letters.”
kb = kilobyte (1024)
mb = megabyte (1024 x 1024)
gb = gigabyte (1024 x 1024 x 1024)
tb = terabyte (1024 x 1024 x 1024 x 1024)
pb = petabyte (1024 x 1024 x 1024 x 1024 x 1024)
#tip
Today's tip ‣ Arrays: Common
”A 1-dimensional array has type `type[]`, a 2-dimensional array has type `type[,]`, a 3-dimensional array has type `type[,,]`, and so on, where type is object for an unconstrained type array, or the constrained type for a constrained array.”
#tip
”A 1-dimensional array has type `type[]`, a 2-dimensional array has type `type[,]`, a 3-dimensional array has type `type[,,]`, and so on, where type is object for an unconstrained type array, or the constrained type for a constrained array.”
$a = [int[]](1,2,3,4) # constrained to int
#tip
Today's tip ‣ Hashtables: Hashtable creation
”A `Hashtable` is created via a hash literal @{} or the New-Object cmdlet. It can be created with zero or more elements. The Count property returns the current element count.”
#tip
”A `Hashtable` is created via a hash literal @{} or the New-Object cmdlet. It can be created with zero or more elements. The Count property returns the current element count.”
#tip
Today's tip ‣ Variables: Variable categories
”PowerShell defines the following categories of variables: static variables, instance variables, array elements, Hashtable key/value pairs, parameters, ordinary variables, and variables on provider drives.”
#tip
”PowerShell defines the following categories of variables: static variables, instance variables, array elements, Hashtable key/value pairs, parameters, ordinary variables, and variables on provider drives.”
- `[Math::PI]` is a static variable
- `$date.Month` is an instance variable
- `$values[2]` is an array element
- `$h1.FirstName` is a `Hashtable` key whose corresponding value is $h1['FirstName']`
- `$p1` and `$p2` are parameters
- `$radius`, `$circumference`, `$date`, `$month`, `$values`, `$value`, and `$h1` are ordinary variables
- `$Alias:A`, `$Env:MyPath`, `${E:output.txt}`, and `$function:F` are variables on the corresponding provider drives.
- `$Variable:v` is actually an ordinary variable written with its fully qualified provider drive.
#tip
👍3
Today's tip ‣ Hashtables: Common
”The type Hashtable represents a collection of key/value pair objects that supports efficient retrieval of a value when indexed by the key. Each key/value pair is an element, which is stored in some implementation-defined object type.”
#tip
”The type Hashtable represents a collection of key/value pair objects that supports efficient retrieval of a value when indexed by the key. Each key/value pair is an element, which is stored in some implementation-defined object type.”
#tip
👍1
Today's tip ‣ Basic concepts: Dot source notation
”When dot source notation is used, no new scope is created before the command is executed, so additions/changes it would have made to its own local scope are made to the current scope instead.”
#tip
”When dot source notation is used, no new scope is created before the command is executed, so additions/changes it would have made to its own local scope are made to the current scope instead.”
Script2.ps1
. "Script2.ps1"
. { ... }
. FunctionA
#tip
👍2❤1