New-Variable
SYNOPSIS
Creates a new variable.
SYNTAX
New-Variable [-name] <string> [[-value] <Object>] [-scope <string>] [-description <string>] [-option {<None> | <ReadOnly> | <Constant> | <Private> | <AllScope>}] [-force] [-passThru] [-whatIf] [-confirm] [<CommonParameters>]
DETAILED DESCRIPTION
Creates a new variable. It does not, by default, assign a value to the variable.
PARAMETERS
-name <string>
The name of the new variable
Required? |
true |
Position? |
1 |
Default value |
N/A - The Name must be specified |
Accept pipeline input? |
true (ByPropertyName) |
Accept wildcard characters? |
false |
-value <Object>
The value assigned to the variable
Required? |
false |
Position? |
2 |
Default value |
Null (...AutomationValue.Null) |
Accept pipeline input? |
true (ByValue, ByPropertyName) |
Accept wildcard characters? |
false |
-scope <string>
The scope from which the aliases should be exported. This can be a named scope: "global", "local", or "script", or it can be a number relative to the current scope (0 through the number of scopes where 0 is the current scope and 1 is its parent).
Required? |
false |
Position? |
named |
Default value |
Local |
Accept pipeline input? |
false |
Accept wildcard characters? |
false |
-description <string>
User-supplied description of the variable
Required? |
false |
Position? |
named |
Default value |
Null |
Accept pipeline input? |
false |
Accept wildcard characters? |
false |
-option <ScopedItemOptions>
Possible values include ReadOnly, Constant and Private. Any combination of these may be given.
The following lists the acceptable values for this parameter:
· None
· ReadOnly
· Constant
· Private
· AllScope
Required? |
false |
Position? |
named |
Default value |
null |
Accept pipeline input? |
false |
Accept wildcard characters? |
false |
-force <SwitchParameter>
Allows Cmdlet to override restrictions such as renaming existing files as long as security is not compromised. Used to force the operation to make the best attempt at setting the variable.
Required? |
false |
Position? |
named |
Default value |
False |
Accept pipeline input? |
false |
Accept wildcard characters? |
false |
-passThru <SwitchParameter>
Passes the object created by this cmdlet through the pipeline. By default, this cmdlet does not pass any objects through the pipeline.
Required? |
false |
Position? |
named |
Default value |
False |
Accept pipeline input? |
false |
Accept wildcard characters? |
false |
-whatIf
Describes what would happen if you executed the command without actually executing the command.
Required? |
false |
Position? |
named |
Default value |
|
Accept pipeline input? |
false |
Accept wildcard characters? |
false |
-confirm
Prompts you for confirmation before executing the command.
Required? |
false |
Position? |
named |
Default value |
|
Accept pipeline input? |
false |
Accept wildcard characters? |
false |
<CommonParameters>
This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, and -OutVariable. For more information, type, "get-help about_commonparameters".
INPUT TYPE
String
NOTES
For more information, type "Get-Help New-Variable -detailed". For technical information, type "Get-Help New-Variable -full".
When specifying multiple values for a parameter, use commas to separate the values. For example, "<parameter-name> <value1>, <value2>".
EXAMPLE 1
new-variable days
This command creates a new variable named days. It has no value immediately following the command.
EXAMPLE 2
new-variable zipcode -value 98033
This command creates a variable named zipcode and assigns it the value 98033.
RELATED LINKS