GetNewClosure Instance method scriptblock /none Retrieves a script block that is bound to a module. Any local variables that are in the context of the caller will be copied into the module. Invoke Instance method Collection of object/object[] Invokes the script block with the specified arguments and returns the results. InvokeReturnAsIs Instance method object/object[] Invokes the script block with the specified arguments and returns any objects generated. Create Static method scriptblock /string Creates a new scriptblock object that contains the specified script. Windows PowerShell: scriptblock maps to System.Management.Automation.ScriptBlock. Windows PowerShell: Invoke returns a collection of PsObject. The math type Type math provides access to some constants and methods useful in mathematical computations. It has the following accessible members: Member Member Kind Type Purpose E Static property (read-only) double Natural logarithmic base PI Static property (read-only) double Ratio of the circumference of a circle to its diameter Abs Static method numeric/numeric Absolute value (the return type is the same as the type of the argument passed in) Acos Static method double / double Angle whose cosine is the specified number Asin Static method double / double Angle whose sine is the specified number Atan Static method double / double Angle whose tangent is the specified number Atan2 Static method double / double y, double x Angle whose tangent is the quotient of two specified numbers x and y Ceiling Static method decimal / decimal double / double smallest integer greater than or equal to the specified number
Description Instance property (read-write) string The description of the drive Name Instance property (read-only) string The name of the drive Root Instance property (read-only) string The name of the drive Windows PowerShell: This type is System.Management.Automation.PSDriveInfo. Variable description type This type encapsulates the state of a variable. It has the following accessible members: Member Member Kind Type Purpose Attributes Instance property (read-only) Implementation defined A collection of attributes Description Instance property (read-write) string The description assigned to the variable via the New-Variable (§13.37) or Set-Variable (§13.50) cmdlets. Module Instance property (read-only) Implementation defined (§4.5.12) The module from which this variable was exported ModuleName Instance property (read-only) string The module in which this variable was defined Name Instance property (read-only) string The name assigned to the variable when it was created in the PowerShell language or via the (§13.37) and Set-Variable (§13.50) cmdlets. Options Instance property (read-write) string The options assigned to the variable via the (§13.37) or Set-Variable (§13.50) cmdlets.
OutputType Instance property (read-only) Implementation defined collection Specifies the types of the values output by the command to which the alias refers. Parameters Instance property (read-only) Implementation defined collection The parameters of the command. ParameterSets Instance property (read-only) Implementation defined collection Information about the parameter sets associated with the command. ReferencedCommand Instance property (read-only) Implementation defined Information about the command that is immediately referenced by this alias. ResolvedCommand Instance property (read-only) Implementation defined Information about the command to which the alias eventually resolves. Windows PowerShell: This type is System.Management.Automation.AliasInfo. Working location description type This type encapsulates the state of a working location. It has the following accessible members: Member Member Kind Type Purpose Drive Instance property (read-only) Implementation defined (§4.5.2) A drive description object Path Instance property (read-only) string The working location Provider Instance property (read-only) Implementation defined (§4.5.1) The provider ProviderPath Instance property (read-only) string The current path of the provider
HelpFile Instance property string The path to the Help file for the cmdlet. ImplementingType Instance property Implementation defined The type that implements the cmdlet. Module Instance property (read-only) Implementation defined (§4.5.12) The module that defines this cmdlet. ModuleName Instance property (read-only) string The name of the module that defines the cmdlet. Name Instance property (read-only) string The name of the cmdlet. Noun Instance property (read-only) string The noun name of the cmdlet. OutputType Instance property (read-only) Implementation defined collection Specifies the types of the values output by the cmdlet. Parameters Instance property (read-only) Implementation defined collection The parameters of the cmdlet. ParameterSets Instance property (read-only) Implementation defined collection Information about the parameter sets associated with the cmdlet. Verb Instance property (read-only) string The verb name of the cmdlet.
Description Instance property string The description of the function. Module Instance property (read-only) Implementation defined (§4.5.12) The module from which this function was exported ModuleName Instance property (read-only) string The module in which this function was defined Name Instance property (read-only) string The name of the function Options Instance property Implementation defined The scope options for the function (§3.5.4). OutputType Instance property (read-only) Implementation defined collection Specifies the types of the values output, in order (see §12.3.6). Parameters Instance property (read-only) Implementation defined collection Specifies the parameter names, in order. If the function acts like a cmdlet (see CmdletBinding above) the common parameters (§13.56) are included at the end of the collection. ParameterSets Instance property (read-only) Implementation defined collection Information about the parameter sets associated with the command. For each parameter, the result shows the parameter name and type, and indicates if the parameter is mandatory, by position or a switch parameter. If the function acts like a cmdlet (see CmdletBinding above) the common parameters (§13.56) are included at the end of the collection. ScriptBlock Instance property (read-only) scriptblock (§4.3.6) The body of the function
CreationTime Instance property (read-write) Implementation defined (§4.5.19) Gets and sets the creation time of the file object. Extension Instance property (read- only) string Gets the extension part of the file name. FullName Instance property (read-only) string Gets the full path of the file. LastWriteTime Instance property (read-write) Implementation defined (§4.5.19) Gets and sets the time when the file was last written to. Length Instance property (read- only) long Gets the size of the file, in bytes. Name Instance property (read- only) string Gets the name of the file. VersionInfo Instance property only) Implementation defined Windows PowerShell: This ScriptProperty returns a System.Diagnostics.FileVersionInfo for the file. Windows PowerShell: This type is System.IO.FileInfo. Date-Time description type The type of a date-time description object is implementation defined; it has the following accessible members: Member Member Kind Type Purpose Day Instance property (read-only) int Gets the day component of the month represented by this instance.
Hour Instance property (read-only) int Gets the hour component of the date represented by this instance. Minute Instance property (read-only) int Gets the minute component of the date represented by this instance. Month Instance property (read-only) int Gets the month component of the date represented by this instance. Second Instance property (read-only) int Gets the seconds component of the date represented by this instance. Year Instance property (read-only) int Gets the year component of the date represented by this instance. An object of this type can be created by cmdlet Get-Date (§13.18). Windows PowerShell: This type is System.DateTime. Group-Info description type The type of a group-info description object is implementation defined; it has the following accessible members: Member Member Kind Type Purpose Count Instance property (read-only) int Gets the number of elements in the group. Group Instance property (read-only) collection Gets the elements of the group. Name Instance property (read-only) string Gets the name of the group.
Examples: $a = [int[]](10,20) # [int[]], Length 2 $a + "red" # [object[]], Length 3 $a + 12.5,$true # [object[]], Length 4 $a + (New-Object 'float[,]' 2,3) # [object[]], Length 8 (New-Object 'float[,]' 2,3) + $a # [object[]], Length 8 Hashtable concatenation Description: When both operands designate Hashtables the binary + operator creates a new Hashtable that contains the elements designated by the left operand followed immediately by the elements designated by the right operand. If the Hashtables contain the same key, an implementation-defined terminating error is raised.. This operator is left associative. Examples: $h1 = @{ FirstName = "James"; LastName = "Anderson" } $h2 = @{ Dept = "Personnel" } $h3 = $h1 + $h2 # new Hashtable, Count = 3 Windows PowerShell: If the Hashtables contain the same key, an exception of type BadOperatorArgument is raised. Subtraction Description: The result of the subtraction operator - is the difference when the value designated by the right operand is subtracted from the value designated by the left operand after the usual arithmetic conversions (§6.15) have been applied. This operator is left associative. Examples: 12 - -10L # long result 2c -10.300D - 12 # decimal result -22.300 10.6 - 12 # double result -1.4 12 - "0xabc" # int result -2736
(named) Type: bool; Default value: $false This argument specifies whether the parameter accepts all of the remaining arguments that are not bound to the parameters of the function. A value of $true indicates that it does. A value of $false indicates that it does not. The following example shows a parameter $others that accepts all the remaining arguments of the input object that is passed to the function Test: param ( [parameter(Mandatory = $true)][int] $p1, [parameter(Mandatory = $true)][int] $p2, [parameter(ValueFromRemainingArguments = $true)] [string[]] $others ) Test 10 20 # $others has Length 0 Test 10 20 30 40 # $others has Length 2, value 30,40 An implementation may define other attributes as well. Windows PowerShell: The following attributes are provided as well: HelpMessageBaseName: Specifies the location where resource identifiers reside. For example, this parameter could specify a resource assembly that contains Help messages that are to be localized. HelpMessageResourceId: Specifies the resource identifier for a Help message. The ValidateCount attribute This attribute is used in a script-parameter to specify the minimum and maximum number of argument values that the parameter can accept. The following arguments are used to define the characteristics of the parameter: Parameter Name Purpose MinLength (position 0) Type: int This argument specifies the minimum number of argument values allowed. MaxLength (position 1) Type: int This argument specifies the maximum number of argument values allowed. In the absence of this attribute, the parameter's corresponding argument value list can be of any length. Consider a function call Test that has the following param block, and which is called as shown: param ( [ValidateCount(2,5)] [int[]] $Values )
Comment-Based Help PowerShell provides a mechanism for programmers to document their scripts using special comment directives. Comments using such syntax are called help comments. The cmdlet Get-Help (§13.19) generates documentation from these directives. Introduction A help comment contains a help directive of the form .name followed on one or more subsequent lines by the help content text. The help comment can be made up of a series of single-line-comments or a (§2.2.3). The set of comments comprising the documentation for a single entity is called a help topic. For example, # <help-directive-1> # <help-content-1> … # <help-directive-n> # <help-content-n> or <# <help-directive-1> <help-content-1> … <help-directive-n> <help-content-n> #> All of the lines in a help topic must be contiguous. If a help topic follows a comment that is not part of that topic, there must be at least one blank line between the two. The directives can appear in any order, and some of the directives may appear multiple times. Directive names are not case-sensitive. When documenting a function, help topics may appear in one of three locations: Immediately before the function definition with no more than one blank line between the last line of the function help and the line containing the function statement. Inside the function's body immediately following the opening curly bracket. Inside the function's body immediately preceding the closing curly bracket. When documenting a script file, help topics may appear in one of two locations: At the beginning of the script file, optionally preceded by comments and blank lines only. If the first item in the script after the help is a function definition, there must be at least two blank lines between