Updates from: 03/31/2021 03:17:46
Service Microsoft Docs article Related commit history on GitHub Change details
Microsoft.PowerShell.Core About Assignment Operators (5.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/5.1/Microsoft.PowerShell.Core/About/about_Assignment_Operators.md
--- description: Describes how to use operators to assign values to variables. Locale: en-US Previously updated : 04/26/2020 Last updated : 03/30/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_assignment_operators?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about_Assignment_Operators
Tuesday, May 31, 2005 12:00:00 AM
In PowerShell, you can assign values to multiple variables by using a single command. The first element of the assignment value is assigned to the first variable, the second element is assigned to the second variable, the third
-element to the third variable, and so on. For example, the following command
-assigns the value 1 to the `$a` variable, the value 2 to the `$b` variable, and
-the value 3 to the `$c` variable:
+element to the third variable, and so on. This is known as _multiple
+assignment_.
+
+For example, the following command assigns the value 1 to the `$a` variable,
+the value 2 to the `$b` variable, and the value 3 to the `$c` variable:
```powershell $a, $b, $c = 1, 2, 3
$d, $e, $f = $c
This command assigns the value 3 to the `$d` variable, the value 4 to the `$e` variable, and the value 5 to the `$f` variable.
-If the assignment value contains less elements than variables, all the
-remaining variables at the end are not assigned any values. For example, the
+If the assignment value contains fewer elements than variables, the
+remaining variables are assigned the value `$null`. For example, the
following command contains three variables and two values: ```powershell
$a, $b, $c = 1, 2
``` Therefore, PowerShell assigns the value 1 to the `$a` variable and the value 2
-to the `$b` variable. It will not assign any value to the `$c` variable.
+to the `$b` variable. The `$c` variable is `$null`.
You can also assign a single value to multiple variables by chaining the variables. For example, the following command assigns a value of "three" to all
Microsoft.PowerShell.Core About Split (5.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/5.1/Microsoft.PowerShell.Core/About/about_Split.md
---
-description: Explains how to use the Split operator to split one or more strings into substrings.
-keywords: powershell,cmdlet
+description: Explains how to use the Split operator to split one or more strings into substrings.
Locale: en-US Previously updated : 12/20/2017 Last updated : 03/30/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_split?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about_Split ---- # About Split ## SHORT DESCRIPTION- Explains how to use the Split operator to split one or more strings into substrings.
change the following elements of the Split operation:
- Delimiter. The default is whitespace, but you can specify characters, strings, patterns, or script blocks that specify the delimiter. The Split
- operator in Windows PowerShell uses a regular expression in the delimiter,
+ operator in PowerShell uses a regular expression in the delimiter,
rather than a simple character. - Maximum number of substrings. The default is to return all substrings. If you specify a number less than the number of substrings, the remaining
whitespace, including spaces and non-printable characters, such as newline
(\`n) and tab (\`t). When the strings are split, the delimiter is omitted from all the substrings. Example:
-```
+```powershell
"Lastname:FirstName:Address" -split ":" Lastname FirstName
Address
By default, the delimiter is omitted from the results. To preserve all or part of the delimiter, enclose in parentheses the part that you want to preserve.
-If the \<Max-substrings\> parameter is added, this takes precedence when your
+If the `<Max-substrings>` parameter is added, this takes precedence when your
command splits up the collection. If you opt to include a delimiter as part of the output, the command returns the delimiter as part of the output; however, splitting the string to return the delimiter as part of output does not count
as a split.
Examples:
-```
+```powershell
"Lastname:FirstName:Address" -split "(:)" Lastname :
FirstName
Address ```
-In the following example, \<Max-substrings\> is set to 3. This results in
-three splits of the string values, but a total of five strings in the
-resulting output; the delimiter is included after the splits, until the
-maximum of three substrings is reached. Additional delimiters in the final
-substring become part of the substring.
-
-```powershell
-'Chocolate-Vanilla-Strawberry-Blueberry' -split '(-)', 3
-```
-
-```output
-Chocolate
--
-Vanilla
--
-Strawberry-Blueberry
-```
-
-### \<Max-substrings\>
+### `<Max-substrings>`
-Specifies the maximum number of times that a string is split. The default is
-all the substrings split by the delimiter. If there are more substrings, they
-are concatenated to the final substring. If there are fewer substrings, all
-the substrings are returned. A value of 0 and negative values return all the
+Specifies the maximum number of substrings returned by the split operation. The
+default is all substrings split by the delimiter. If there are more
+substrings, they are concatenated to the final substring. If there are fewer
+substrings, all substrings are returned. A value of 0 returns all the
substrings.
-Max-substrings does not specify the maximum number of objects that are
-returned; its value equals the maximum number of times that a string is split.
-If you submit more than one string (an array of strings) to the Split operator
-, the Max-substrings limit is applied to each string separately.
- Example: ```powershell
$c = "Mercury,Venus,Earth,Mars,Jupiter,Saturn,Uranus,Neptune"
$c -split ",", 5 ```
-```output
+```Output
Mercury Venus Earth
Mars
Jupiter,Saturn,Uranus,Neptune ```
+If you submit more than one string (an array of strings) to the `-split`
+operator, the `Max-substrings` limit is applied to each string separately.
+
+```powershell
+$c = 'a,b,c','1,2,3,4,5'
+$c -split ',', 3
+
+a
+b
+c
+1
+2
+3,4,5
+```
+
+`<Max-substrings>` does not specify the maximum number of objects that are
+returned. In the following example, `<Max-substrings>` is set to 3.
+This results in three substring values, but a total of five strings
+in the resulting output. The delimiter is included after the splits until the
+maximum of three substrings is reached. Additional delimiters in the final
+substring become part of the substring.
+
+```powershell
+'Chocolate-Vanilla-Strawberry-Blueberry' -split '(-)', 3
+```
+
+```Output
+Chocolate
+-
+Vanilla
+-
+Strawberry-Blueberry
+```
+
+Negative values are ignored.
++ ### \<ScriptBlock\> An expression that specifies rules for applying the delimiter. The expression
$c = "Mercury,Venus,Earth,Mars,Jupiter,Saturn,Uranus,Neptune"
$c -split {$_ -eq "e" -or $_ -eq "p"} ```
-```output
+```Output
M rcury,V nus,
The following statement splits the string at whitespace.
-split "Windows PowerShell 2.0`nWindows PowerShell with remoting" ```
-```output
+```Output
Windows PowerShell
The following statement splits the string at any comma.
"Mercury,Venus,Earth,Mars,Jupiter,Saturn,Uranus,Neptune" -split ',' ```
-```output
+```Output
Mercury Venus Earth
The following statement splits the string at the pattern "er".
"Mercury,Venus,Earth,Mars,Jupiter,Saturn,Uranus,Neptune" -split 'er' ```
-```output
+```Output
M cury,Venus,Earth,Mars,Jupit ,Saturn,Uranus,Neptune
The following statement performs a case-sensitive split at the letter "N".
"Mercury,Venus,Earth,Mars,Jupiter,Saturn,Uranus,Neptune" -cSplit 'N' ```
-```output
+```Output
Mercury,Venus,Earth,Mars,Jupiter,Saturn,Uranus, eptune ```
The following statement splits the string at "e" and "t".
"Mercury,Venus,Earth,Mars,Jupiter,Saturn,Uranus,Neptune" -split '[et]' ```
-```output
+```Output
M rcury,V nus,
resulting substrings to six substrings.
"Mercury,Venus,Earth,Mars,Jupiter,Saturn,Uranus,Neptune" -split '[er]', 6 ```
-```output
+```Output
M cu
The following statement splits a string into three substrings.
"a,b,c,d,e,f,g,h" -split ",", 3 ```
-```output
+```Output
a b c,d,e,f,g,h
The following statement splits two strings into three substrings.
"a,b,c,d", "e,f,g,h" -split ",", 3 ```
-```output
+```Output
a b c,d
newline.
"This.is.a.test" -split "\." ```
-```output
+```Output
This is a
specified.
"This.is.a.test" -split ".", 0, "simplematch" ```
-```output
+```Output
This is a
$c = "LastName, FirstName; Address, City, State, Zip"
$c -split $(if ($i -lt 1) {","} else {";"}) ```
-```output
+```Output
LastName, FirstName Address, City, State, Zip ```
Microsoft.PowerShell.Core About Variables (5.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/5.1/Microsoft.PowerShell.Core/About/about_Variables.md
---
-description: Describes how variables store values that can be used in PowerShell.
-keywords: powershell,cmdlet
+description: Describes how variables store values that can be used in PowerShell.
Locale: en-US Previously updated : 11/09/2020 Last updated : 03/30/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_variables?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about_Variables
Remove-Variable -Name MyVariable
Remove-Item -Path Variable:\MyVariable ```
+It is also possible to values to multiple variables with one statement. The
+following examples assigns the same value to multiple variables:
+
+```powershell
+$a = $b = $c = 0
+```
+
+The next example assigns multiple values to multiple variables.
+
+```powershell
+$i,$j,$k = 10, "red", $true # $i is 10, $j is "red", $k is True
+$i,$j = 10, "red", $true # $i is 10, $j is [object[]], Length 2
+```
+
+For more detailed information, see the **Assigning multiple variables** section
+of [about_Assignment_Operators](about_assignment_operators.md#assigning-multiple-variables).
+ ## Types of variables You can store any type of object in a variable, including integers, strings,
Microsoft.PowerShell.LocalAccounts Get Localuser (5.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/5.1/Microsoft.PowerShell.LocalAccounts/Get-LocalUser.md
Name Enabled Description
MicrosoftAccount\username@outlook.com True Description of this account. ```
-### Example 3: Get an account that is connected to a Microsoft account
+### Example 3: Get an account that has the specified SID
This example gets a local user account that has the specified SID.
Microsoft.PowerShell.Utility New Variable (5.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/5.1/Microsoft.PowerShell.Utility/New-Variable.md
external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml
keywords: powershell,cmdlet Locale: en-US Module Name: Microsoft.PowerShell.Utility Previously updated : 06/09/2017 Last updated : 03/30/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/new-variable?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: New-Variable
Title: New-Variable
# New-Variable
-## SYNOPSIS
+## Synopsis
Creates a new variable.
-## SYNTAX
+## Syntax
``` New-Variable [-Name] <String> [[-Value] <Object>] [-Description <String>] [-Option <ScopedItemOptions>]
New-Variable [-Name] <String> [[-Value] <Object>] [-Description <String>] [-Opti
[<CommonParameters>] ```
-## DESCRIPTION
-The **New-Variable** cmdlet creates a new variable in Windows PowerShell.
-You can assign a value to the variable while creating it or assign or change the value after it is created.
+## Description
-You can use the parameters of **New-Variable** to set the properties of the variable, set the scope of a variable, and determine whether variables are public or private.
+The `New-Variable` cmdlet creates a new variable in Windows PowerShell. You can assign a value to
+the variable while creating it or assign or change the value after it is created.
-Typically, you create a new variable by typing the variable name and its value, such as `$Var = 3`, but you can use the **New-Variable** cmdlet to use its parameters.
+You can use the parameters of `New-Variable` to set the properties of the variable, set the scope of
+a variable, and determine whether variables are public or private.
-## EXAMPLES
+Typically, you create a new variable by typing the variable name and its value, such as `$Var = 3`,
+but you can use the `New-Variable` cmdlet to use its parameters.
+
+## Examples
### Example 1: Create a variable ```
-PS C:\> New-Variable days
+New-Variable days
```
-This command creates a new variable named days.
-You are not required to type the *Name* parameter.
+This command creates a new variable named days. You are not required to type the **Name** parameter.
### Example 2: Create a variable and assign it a value ```
-PS C:\> New-Variable -Name "zipcode" -Value 98033
+New-Variable -Name "zipcode" -Value 98033
``` This command creates a variable named zipcode and assigns it the value 98033.
At line:1 char:1
PS C:\> New-Variable -Name max -Value 1024 -Force ```
-This example shows how to use the ReadOnly option of **New-Variable** to protect a variable from being overwritten.
+This example shows how to use the `ReadOnly` option of `New-Variable` to protect a variable from
+being overwritten.
-The first command creates a new variable named Max and sets its value to 256.
-It uses the *Option* parameter with a value of ReadOnly.
+The first command creates a new variable named Max and sets its value to 256. It uses the **Option**
+parameter with a value of `ReadOnly`.
-The second command tries to create a second variable with the same name.
-This command returns an error, because the read-only option is set on the variable.
+The second command tries to create a second variable with the same name. This command returns an
+error, because the read-only option is set on the variable.
-The third command uses the *Force* parameter to override the read-only protection on the variable.
+The third command uses the **Force** parameter to override the read-only protection on the variable.
In this case, the command to create a new variable with the same name succeeds.
-### Example 4: Create a private variable
+### Example 4: Assign multiple options to a variable
+
+```powershell
+New-Variable -Name 'TestVariable' -Value 'Test Value' -Option AllScope,Constant
+```
+
+This example creates a variable and assigns the `AllScope` and `Constant` options so the variable
+will be available in the current scope and any new scopes created and cannot be changed or deleted.
+
+### Example 5: Create a private variable
``` PS C:\> New-Variable -Name counter -Visibility Private
Counter1 3.1415
... ```
-This command demonstrates the behavior of a private variable in a module.
-The module contains the Get-Counter cmdlet, which has a private variable named Counter.
-The command uses the *Visibility* parameter with a value of Private to create the variable.
+This command demonstrates the behavior of a private variable in a module. The module contains the
+`Get-Counter` cmdlet, which has a private variable named Counter. The command uses the
+**Visibility** parameter with a value of Private to create the variable.
-The sample output shows the behavior of a private variable.
-The user who has loaded the module cannot view or change the value of the Counter variable, but the Counter variable can be read and changed by the commands in the module.
+The sample output shows the behavior of a private variable. The user who has loaded the module
+cannot view or change the value of the Counter variable, but the Counter variable can be read and
+changed by the commands in the module.
-### Example 5: Create a variable with a space
+### Example 6: Create a variable with a space
``` PS C:\> New-Variable -Name 'with space' -Value 'abc123xyz'
PS C:\> ${with space}
abc123xyz ```
-This command demonstrates that variables with spaces can be created.
-The variables can be accessed using the **Get-Variable** cmdlet or directly by delimiting a variable with braces.
+This command demonstrates that variables with spaces can be created. The variables can be accessed
+using the `Get-Variable` cmdlet or directly by delimiting a variable with braces.
-## PARAMETERS
+## Parameters
### -Description+ Specifies a description of the variable. ```yaml
Accept wildcard characters: False
``` ### -Force+ Indicates that the cmdlet creates a variable with the same name as an existing read-only variable.
-By default, you can overwrite a variable unless the variable has an option value of ReadOnly or Constant.
-For more information, see the *Option* parameter.
+By default, you can overwrite a variable unless the variable has an option value of `ReadOnly` or
+`Constant`. For more information, see the **Option** parameter.
```yaml Type: System.Management.Automation.SwitchParameter
Accept wildcard characters: False
``` ### -Name+ Specifies a name for the new variable. ```yaml
Accept wildcard characters: False
``` ### -Option
-Specifies the value of the **Options** property of the variable.The acceptable values for this parameter are:
--- None.
-Sets no options.
-(None is the default.)
-- ReadOnly.
-Can be deleted.
-Cannot be changed, except by using the *Force* parameter.
-- Private.
-The variable is available only in the current scope.
-- AllScope.
-The variable is copied to any new scopes that are created.
-- Constant.
-Cannot be deleted or changed.
-Constant is valid only when you are creating a variable.
-You cannot change the options of an existing variable to Constant.
-
-To see the **Options** property of all variables in the session, type `Get-Variable | Format-Table -Property name, options -autosize`.
+
+Specifies the value of the **Options** property of the variable. The acceptable values for this
+parameter are:
+
+- `None` - Sets no options. `None` is the default.
+- `ReadOnly` - Can be deleted. Cannot be changed, except by using the **Force** parameter.
+- `Private` - The variable is available only in the current scope.
+- `AllScope` - The variable is copied to any new scopes that are created.
+- `Constant` - Cannot be deleted or changed. `Constant` is valid only when you are creating a
+ variable. You cannot change the options of an existing variable to `Constant`.
+
+These values are defined as a flag-based enumeration. You can combine multiple values together to
+set multiple flags using this parameter. The values can be passed to the **Option** parameter as an
+array of values or as a comma-separated string of those values. The cmdlet will combine the values
+using a binary-OR operation. Passing values as an array is the simplest option and also allows you
+to use tab-completion on the values.
+
+To see the Options property of all variables in the session, type
+`Get-Variable | Format-Table -Property name, options -AutoSize`.
```yaml Type: System.Management.Automation.ScopedItemOptions
Accept wildcard characters: False
``` ### -PassThru
-Returns an object representing the item with which you are working.
-By default, this cmdlet does not generate any output.
+
+Returns an object representing the item with which you are working. By default, this cmdlet does not
+generate any output.
```yaml Type: System.Management.Automation.SwitchParameter
Accept wildcard characters: False
``` ### -Scope
-Specifies the scope of the new variable.
-The acceptable values for this parameter are:
-- Global.
-Variables created in the global scope are accessible everywhere in a PowerShell process.
-- Local.
-The local scope refers to the current scope, this can be any scope depending on the context.
-- Script.
-Variables created in the script scope are accessible only within the script file or module they are created in.
-- Private.
-Variables created in the private scope cannot be accessed outside the scope they exist in.
-You can use private scope to create a private version of an item with the same name in another scope.
-- A number relative to the current scope (0 through the number of scopes, where 0 is the current scope, 1 is its parent, 2 the parent of the parent scope, and so on).
-Negative numbers cannot be used.
+Specifies the scope of the new variable. The acceptable values for this parameter are:
+
+- `Global` - Variables created in the global scope are accessible everywhere in a PowerShell
+ process.
+- `Local` - The local scope refers to the current scope, this can be any scope depending on the
+ context.
+- `Script` - Variables created in the script scope are accessible only within the script file or
+ module they are created in.
+- `Private` - Variables created in the private scope cannot be accessed outside the scope they exist
+ in. You can use private scope to create a private version of an item with the same name in another
+ scope.
+- A number relative to the current scope (0 through the number of scopes, where 0 is the current
+ scope, 1 is its parent, 2 the parent of the parent scope, and so on). Negative numbers cannot be
+ used.
-Local is the default scope when the scope parameter is not specified.
+`Local` is the default scope when the scope parameter is not specified.
-For more information, see about_Scopes.
+For more information, see [about_Scopes](../Microsoft.PowerShell.Core/About/about_Scopes.md).
```yaml Type: System.String
Accept wildcard characters: False
``` ### -Value+ Specifies the initial value of the variable. ```yaml
Accept wildcard characters: False
``` ### -Visibility
-Determines whether the variable is visible outside of the session in which it was created.
-This parameter is designed for use in scripts and commands that will be delivered to other users.
-The acceptable values for this parameter are:
-- Public.
-The variable is visible.
-(Public is the default.)
-- Private.
-The variable is not visible.
+Determines whether the variable is visible outside of the session in which it was created. This
+parameter is designed for use in scripts and commands that will be delivered to other users. The
+acceptable values for this parameter are:
+
+- `Public` - The variable is visible. `Public` is the default.
+- `Private` - The variable is not visible.
-When a variable is private, it does not appear in lists of variables, such as those returned by Get-Variable, or in displays of the Variable: drive.
-Commands to read or change the value of a private variable return an error.
-However, the user can run commands that use a private variable if the commands were written in the session in which the variable was defined.
+When a variable is private, it does not appear in lists of variables, such as those returned by
+`Get-Variable`, or in displays of the `Variable:` drive. Commands to read or change the value of a
+private variable return an error. However, the user can run commands that use a private variable if
+the commands were written in the session in which the variable was defined.
```yaml Type: System.Management.Automation.SessionStateEntryVisibility
Accept wildcard characters: False
``` ### -Confirm+ Prompts you for confirmation before running the cmdlet. ```yaml
Accept wildcard characters: False
``` ### -WhatIf
-Shows what would happen if the cmdlet runs.
-The cmdlet is not run.
+
+Shows what would happen if the cmdlet runs. The cmdlet is not run.
```yaml Type: System.Management.Automation.SwitchParameter
Accept wildcard characters: False
``` ### CommonParameters+ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
-## INPUTS
+## Inputs
### System.Object
-You can pipe a value to **New-Variable**.
-## OUTPUTS
+You can pipe a value to `New-Variable`.
+
+## Outputs
### None or System.Management.Automation.PSVariable
-When you use the *PassThru* parameter, **New-Variable** generates a **System.Management.Automation.PSVariable** object representing the new variable.
-Otherwise, this cmdlet does not generate any output.
-## NOTES
+When you use the **PassThru** parameter, `New-Variable` generates a
+**System.Management.Automation.PSVariable** object representing the new variable. Otherwise, this
+cmdlet does not generate any output.
+
+## Notes
-## RELATED LINKS
+## Related Links
[Clear-Variable](Clear-Variable.md)
Microsoft.PowerShell.Core About Assignment Operators (7.0) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.0/Microsoft.PowerShell.Core/About/about_Assignment_Operators.md
--- description: Describes how to use operators to assign values to variables. Locale: en-US Previously updated : 04/26/2020 Last updated : 03/30/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_assignment_operators?view=powershell-7&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about_Assignment_Operators
Tuesday, May 31, 2005 12:00:00 AM
In PowerShell, you can assign values to multiple variables by using a single command. The first element of the assignment value is assigned to the first variable, the second element is assigned to the second variable, the third
-element to the third variable, and so on. For example, the following command
-assigns the value 1 to the `$a` variable, the value 2 to the `$b` variable, and
-the value 3 to the `$c` variable:
+element to the third variable, and so on. This is known as _multiple
+assignment_.
+
+For example, the following command assigns the value 1 to the `$a` variable,
+the value 2 to the `$b` variable, and the value 3 to the `$c` variable:
```powershell $a, $b, $c = 1, 2, 3
$d, $e, $f = $c
This command assigns the value 3 to the `$d` variable, the value 4 to the `$e` variable, and the value 5 to the `$f` variable.
-If the assignment value contains less elements than variables, all the
-remaining variables at the end are not assigned any values. For example, the
+If the assignment value contains fewer elements than variables, the
+remaining variables are assigned the value `$null`. For example, the
following command contains three variables and two values: ```powershell
$a, $b, $c = 1, 2
``` Therefore, PowerShell assigns the value 1 to the `$a` variable and the value 2
-to the `$b` variable. It will not assign any value to the `$c` variable.
+to the `$b` variable. The `$c` variable is `$null`.
You can also assign a single value to multiple variables by chaining the variables. For example, the following command assigns a value of "three" to all
Microsoft.PowerShell.Core About Split (7.0) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.0/Microsoft.PowerShell.Core/About/about_Split.md
---
-description: Explains how to use the Split operator to split one or more strings into substrings.
-keywords: powershell,cmdlet
+description: Explains how to use the Split operator to split one or more strings into substrings.
Locale: en-US Previously updated : 03/24/2020 Last updated : 03/30/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_split?view=powershell-7&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about_Split
whitespace, including spaces and non-printable characters, such as newline
(\`n) and tab (\`t). When the strings are split, the delimiter is omitted from all the substrings. Example:
-```
+```powershell
"Lastname:FirstName:Address" -split ":" Lastname FirstName
Address
By default, the delimiter is omitted from the results. To preserve all or part of the delimiter, enclose in parentheses the part that you want to preserve.
-If the \<Max-substrings\> parameter is added, this takes precedence when your
+If the `<Max-substrings>` parameter is added, this takes precedence when your
command splits up the collection. If you opt to include a delimiter as part of the output, the command returns the delimiter as part of the output; however, splitting the string to return the delimiter as part of output does not count
as a split.
Examples:
-```
+```powershell
"Lastname:FirstName:Address" -split "(:)" Lastname :
FirstName
Address ```
-In the following example, \<Max-substrings\> is set to 3. This results in
-three splits of the string values, but a total of five strings in the
-resulting output; the delimiter is included after the splits, until the
+### `<Max-substrings>`
+
+Specifies the maximum number of substrings returned by the split operation. The
+default is all substrings split by the delimiter. If there are more
+substrings, they are concatenated to the final substring. If there are fewer
+substrings, all substrings are returned. A value of 0 returns all the
+substrings.
+
+Example:
+
+```powershell
+$c = "Mercury,Venus,Earth,Mars,Jupiter,Saturn,Uranus,Neptune"
+$c -split ",", 5
+```
+
+```Output
+Mercury
+Venus
+Earth
+Mars
+Jupiter,Saturn,Uranus,Neptune
+```
+
+If you submit more than one string (an array of strings) to the `-split`
+operator, the `Max-substrings` limit is applied to each string separately.
+
+```powershell
+$c = 'a,b,c','1,2,3,4,5'
+$c -split ',', 3
+
+a
+b
+c
+1
+2
+3,4,5
+```
+
+`<Max-substrings>` does not specify the maximum number of objects that are
+returned. In the following example, `<Max-substrings>` is set to 3.
+This results in three substring values, but a total of five strings
+in the resulting output. The delimiter is included after the splits until the
maximum of three substrings is reached. Additional delimiters in the final substring become part of the substring.
Vanilla
Strawberry-Blueberry ```
-### \<Max-substrings\>
-
-Specifies the maximum number of times that a string is split. The default is
-all the substrings split by the delimiter. If there are more substrings, they
-are concatenated to the final substring. If there are fewer substrings, all
-the substrings are returned. A value of 0 returns all the substrings. Negative
-values return the amount of substrings requested starting from the end of the
-input string.
+Negative values return the amount of substrings requested starting
+from the end of the input string.
> [!NOTE] > Support for negative values was added in PowerShell 7.
-**Max-substrings** does not specify the maximum number of objects that are
-returned. Its value equals the maximum number of times that a string is split.
-If you submit more than one string (an array of strings) to the `-split`
-operator, the **Max-substrings** limit is applied to each string separately.
-
-Example:
-
-```powershell
-$c = "Mercury,Venus,Earth,Mars,Jupiter,Saturn,Uranus,Neptune"
-$c -split ",", 5
-```
-
-```Output
-Mercury
-Venus
-Earth
-Mars
-Jupiter,Saturn,Uranus,Neptune
-```
- ```powershell $c = "Mercury,Venus,Earth,Mars,Jupiter,Saturn,Uranus,Neptune" $c -split ",", -5
Microsoft.PowerShell.Core About Variables (7.0) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.0/Microsoft.PowerShell.Core/About/about_Variables.md
---
-description: Describes how variables store values that can be used in PowerShell.
-keywords: powershell,cmdlet
+description: Describes how variables store values that can be used in PowerShell.
Locale: en-US Previously updated : 11/09/2020 Last updated : 03/30/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_variables?view=powershell-7&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about_Variables
Remove-Variable -Name MyVariable
Remove-Item -Path Variable:\MyVariable ```
+It is also possible to values to multiple variables with one statement. The
+following examples assigns the same value to multiple variables:
+
+```powershell
+$a = $b = $c = 0
+```
+
+The next example assigns multiple values to multiple variables.
+
+```powershell
+$i,$j,$k = 10, "red", $true # $i is 10, $j is "red", $k is True
+$i,$j = 10, "red", $true # $i is 10, $j is [object[]], Length 2
+```
+
+For more detailed information, see the **Assigning multiple variables** section
+of [about_Assignment_Operators](about_assignment_operators.md#assigning-multiple-variables).
+ ## Types of variables You can store any type of object in a variable, including integers, strings,
Microsoft.PowerShell.Utility New Variable (7.0) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.0/Microsoft.PowerShell.Utility/New-Variable.md
external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml
keywords: powershell,cmdlet Locale: en-US Module Name: Microsoft.PowerShell.Utility Previously updated : 06/09/2017 Last updated : 03/30/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/new-variable?view=powershell-7&WT.mc_id=ps-gethelp schema: 2.0.0 Title: New-Variable
Title: New-Variable
# New-Variable
-## SYNOPSIS
+## Synopsis
Creates a new variable.
-## SYNTAX
+## Syntax
``` New-Variable [-Name] <String> [[-Value] <Object>] [-Description <String>] [-Option <ScopedItemOptions>]
New-Variable [-Name] <String> [[-Value] <Object>] [-Description <String>] [-Opti
[<CommonParameters>] ```
-## DESCRIPTION
-The **New-Variable** cmdlet creates a new variable in PowerShell.
-You can assign a value to the variable while creating it or assign or change the value after it is created.
+## Description
-You can use the parameters of **New-Variable** to set the properties of the variable, set the scope of a variable, and determine whether variables are public or private.
+The `New-Variable` cmdlet creates a new variable in Windows PowerShell. You can assign a value to
+the variable while creating it or assign or change the value after it is created.
-Typically, you create a new variable by typing the variable name and its value, such as `$Var = 3`, but you can use the **New-Variable** cmdlet to use its parameters.
+You can use the parameters of `New-Variable` to set the properties of the variable, set the scope of
+a variable, and determine whether variables are public or private.
-## EXAMPLES
+Typically, you create a new variable by typing the variable name and its value, such as `$Var = 3`,
+but you can use the `New-Variable` cmdlet to use its parameters.
+
+## Examples
### Example 1: Create a variable ```
-PS C:\> New-Variable days
+New-Variable days
```
-This command creates a new variable named days.
-You are not required to type the *Name* parameter.
+This command creates a new variable named days. You are not required to type the **Name** parameter.
### Example 2: Create a variable and assign it a value ```
-PS C:\> New-Variable -Name "zipcode" -Value 98033
+New-Variable -Name "zipcode" -Value 98033
``` This command creates a variable named zipcode and assigns it the value 98033.
At line:1 char:1
PS C:\> New-Variable -Name max -Value 1024 -Force ```
-This example shows how to use the ReadOnly option of **New-Variable** to protect a variable from being overwritten.
+This example shows how to use the `ReadOnly` option of `New-Variable` to protect a variable from
+being overwritten.
-The first command creates a new variable named Max and sets its value to 256.
-It uses the *Option* parameter with a value of ReadOnly.
+The first command creates a new variable named Max and sets its value to 256. It uses the **Option**
+parameter with a value of `ReadOnly`.
-The second command tries to create a second variable with the same name.
-This command returns an error, because the read-only option is set on the variable.
+The second command tries to create a second variable with the same name. This command returns an
+error, because the read-only option is set on the variable.
-The third command uses the *Force* parameter to override the read-only protection on the variable.
+The third command uses the **Force** parameter to override the read-only protection on the variable.
In this case, the command to create a new variable with the same name succeeds.
-### Example 4: Create a private variable
+### Example 4: Assign multiple options to a variable
+
+```powershell
+New-Variable -Name 'TestVariable' -Value 'Test Value' -Option AllScope,Constant
+```
+
+This example creates a variable and assigns the `AllScope` and `Constant` options so the variable
+will be available in the current scope and any new scopes created and cannot be changed or deleted.
+
+### Example 5: Create a private variable
``` PS C:\> New-Variable -Name counter -Visibility Private
Counter1 3.1415
... ```
-This command demonstrates the behavior of a private variable in a module.
-The module contains the Get-Counter cmdlet, which has a private variable named Counter.
-The command uses the *Visibility* parameter with a value of Private to create the variable.
+This command demonstrates the behavior of a private variable in a module. The module contains the
+`Get-Counter` cmdlet, which has a private variable named Counter. The command uses the
+**Visibility** parameter with a value of Private to create the variable.
-The sample output shows the behavior of a private variable.
-The user who has loaded the module cannot view or change the value of the Counter variable, but the Counter variable can be read and changed by the commands in the module.
+The sample output shows the behavior of a private variable. The user who has loaded the module
+cannot view or change the value of the Counter variable, but the Counter variable can be read and
+changed by the commands in the module.
-### Example 5: Create a variable with a space
+### Example 6: Create a variable with a space
``` PS C:\> New-Variable -Name 'with space' -Value 'abc123xyz'
PS C:\> ${with space}
abc123xyz ```
-This command demonstrates that variables with spaces can be created.
-The variables can be accessed using the **Get-Variable** cmdlet or directly by delimiting a variable with braces.
+This command demonstrates that variables with spaces can be created. The variables can be accessed
+using the `Get-Variable` cmdlet or directly by delimiting a variable with braces.
-## PARAMETERS
+## Parameters
### -Description+ Specifies a description of the variable. ```yaml
Accept wildcard characters: False
``` ### -Force+ Indicates that the cmdlet creates a variable with the same name as an existing read-only variable.
-By default, you can overwrite a variable unless the variable has an option value of ReadOnly or Constant.
-For more information, see the *Option* parameter.
+By default, you can overwrite a variable unless the variable has an option value of `ReadOnly` or
+`Constant`. For more information, see the **Option** parameter.
```yaml Type: System.Management.Automation.SwitchParameter
Accept wildcard characters: False
``` ### -Name+ Specifies a name for the new variable. ```yaml
Accept wildcard characters: False
``` ### -Option
-Specifies the value of the **Options** property of the variable.The acceptable values for this parameter are:
--- None.
-Sets no options.
-(None is the default.)
-- ReadOnly.
-Can be deleted.
-Cannot be changed, except by using the *Force* parameter.
-- Private.
-The variable is available only in the current scope.
-- AllScope.
-The variable is copied to any new scopes that are created.
-- Constant.
-Cannot be deleted or changed.
-Constant is valid only when you are creating a variable.
-You cannot change the options of an existing variable to Constant.
-
-To see the **Options** property of all variables in the session, type `Get-Variable | Format-Table -Property name, options -autosize`.
+
+Specifies the value of the **Options** property of the variable. The acceptable values for this
+parameter are:
+
+- `None` - Sets no options. `None` is the default.
+- `ReadOnly` - Can be deleted. Cannot be changed, except by using the **Force** parameter.
+- `Private` - The variable is available only in the current scope.
+- `AllScope` - The variable is copied to any new scopes that are created.
+- `Constant` - Cannot be deleted or changed. `Constant` is valid only when you are creating a
+ variable. You cannot change the options of an existing variable to `Constant`.
+
+These values are defined as a flag-based enumeration. You can combine multiple values together to
+set multiple flags using this parameter. The values can be passed to the **Option** parameter as an
+array of values or as a comma-separated string of those values. The cmdlet will combine the values
+using a binary-OR operation. Passing values as an array is the simplest option and also allows you
+to use tab-completion on the values.
+
+To see the Options property of all variables in the session, type
+`Get-Variable | Format-Table -Property name, options -AutoSize`.
```yaml Type: System.Management.Automation.ScopedItemOptions
Accept wildcard characters: False
``` ### -PassThru
-Returns an object representing the item with which you are working.
-By default, this cmdlet does not generate any output.
+
+Returns an object representing the item with which you are working. By default, this cmdlet does not
+generate any output.
```yaml Type: System.Management.Automation.SwitchParameter
Accept wildcard characters: False
``` ### -Scope
-Specifies the scope of the new variable.
-The acceptable values for this parameter are:
-- Global.
-Variables created in the global scope are accessible everywhere in a PowerShell process.
-- Local.
-The local scope refers to the current scope, this can be any scope depending on the context.
-- Script.
-Variables created in the script scope are accessible only within the script file or module they are created in.
-- Private.
-Variables created in the private scope cannot be accessed outside the scope they exist in.
-You can use private scope to create a private version of an item with the same name in another scope.
-- A number relative to the current scope (0 through the number of scopes, where 0 is the current scope, 1 is its parent, 2 the parent of the parent scope, and so on).
-Negative numbers cannot be used.
+Specifies the scope of the new variable. The acceptable values for this parameter are:
+
+- `Global` - Variables created in the global scope are accessible everywhere in a PowerShell
+ process.
+- `Local` - The local scope refers to the current scope, this can be any scope depending on the
+ context.
+- `Script` - Variables created in the script scope are accessible only within the script file or
+ module they are created in.
+- `Private` - Variables created in the private scope cannot be accessed outside the scope they exist
+ in. You can use private scope to create a private version of an item with the same name in another
+ scope.
+- A number relative to the current scope (0 through the number of scopes, where 0 is the current
+ scope, 1 is its parent, 2 the parent of the parent scope, and so on). Negative numbers cannot be
+ used.
-Local is the default scope when the scope parameter is not specified.
+`Local` is the default scope when the scope parameter is not specified.
-For more information, see about_Scopes.
+For more information, see [about_Scopes](../Microsoft.PowerShell.Core/About/about_Scopes.md).
```yaml Type: System.String
Accept wildcard characters: False
``` ### -Value+ Specifies the initial value of the variable. ```yaml
Accept wildcard characters: False
``` ### -Visibility
-Determines whether the variable is visible outside of the session in which it was created.
-This parameter is designed for use in scripts and commands that will be delivered to other users.
-The acceptable values for this parameter are:
-- Public.
-The variable is visible.
-(Public is the default.)
-- Private.
-The variable is not visible.
+Determines whether the variable is visible outside of the session in which it was created. This
+parameter is designed for use in scripts and commands that will be delivered to other users. The
+acceptable values for this parameter are:
+
+- `Public` - The variable is visible. `Public` is the default.
+- `Private` - The variable is not visible.
-When a variable is private, it does not appear in lists of variables, such as those returned by Get-Variable, or in displays of the Variable: drive.
-Commands to read or change the value of a private variable return an error.
-However, the user can run commands that use a private variable if the commands were written in the session in which the variable was defined.
+When a variable is private, it does not appear in lists of variables, such as those returned by
+`Get-Variable`, or in displays of the `Variable:` drive. Commands to read or change the value of a
+private variable return an error. However, the user can run commands that use a private variable if
+the commands were written in the session in which the variable was defined.
```yaml Type: System.Management.Automation.SessionStateEntryVisibility
Accept wildcard characters: False
``` ### -Confirm+ Prompts you for confirmation before running the cmdlet. ```yaml
Accept wildcard characters: False
``` ### -WhatIf
-Shows what would happen if the cmdlet runs.
-The cmdlet is not run.
+
+Shows what would happen if the cmdlet runs. The cmdlet is not run.
```yaml Type: System.Management.Automation.SwitchParameter
Accept wildcard characters: False
``` ### CommonParameters+ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
-## INPUTS
+## Inputs
### System.Object
-You can pipe a value to **New-Variable**.
-## OUTPUTS
+You can pipe a value to `New-Variable`.
+
+## Outputs
### None or System.Management.Automation.PSVariable
-When you use the *PassThru* parameter, **New-Variable** generates a **System.Management.Automation.PSVariable** object representing the new variable.
-Otherwise, this cmdlet does not generate any output.
-## NOTES
+When you use the **PassThru** parameter, `New-Variable` generates a
+**System.Management.Automation.PSVariable** object representing the new variable. Otherwise, this
+cmdlet does not generate any output.
+
+## Notes
-## RELATED LINKS
+## Related Links
[Clear-Variable](Clear-Variable.md)
Microsoft.PowerShell.Core About Assignment Operators (7.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.1/Microsoft.PowerShell.Core/About/about_Assignment_Operators.md
--- description: Describes how to use operators to assign values to variables. Locale: en-US Previously updated : 04/26/2020 Last updated : 03/30/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_assignment_operators?view=powershell-7.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about_Assignment_Operators
Tuesday, May 31, 2005 12:00:00 AM
In PowerShell, you can assign values to multiple variables by using a single command. The first element of the assignment value is assigned to the first variable, the second element is assigned to the second variable, the third
-element to the third variable, and so on. For example, the following command
-assigns the value 1 to the `$a` variable, the value 2 to the `$b` variable, and
-the value 3 to the `$c` variable:
+element to the third variable, and so on. This is known as _multiple
+assignment_.
+
+For example, the following command assigns the value 1 to the `$a` variable,
+the value 2 to the `$b` variable, and the value 3 to the `$c` variable:
```powershell $a, $b, $c = 1, 2, 3
$d, $e, $f = $c
This command assigns the value 3 to the `$d` variable, the value 4 to the `$e` variable, and the value 5 to the `$f` variable.
-If the assignment value contains less elements than variables, all the
-remaining variables at the end are not assigned any values. For example, the
+If the assignment value contains fewer elements than variables, the
+remaining variables are assigned the value `$null`. For example, the
following command contains three variables and two values: ```powershell
$a, $b, $c = 1, 2
``` Therefore, PowerShell assigns the value 1 to the `$a` variable and the value 2
-to the `$b` variable. It will not assign any value to the `$c` variable.
+to the `$b` variable. The `$c` variable is `$null`.
You can also assign a single value to multiple variables by chaining the variables. For example, the following command assigns a value of "three" to all
Set-Variable -Name a -Value 1, 2, 3
[Remove-Variable](xref:Microsoft.PowerShell.Utility.Remove-Variable) [Set-Variable](xref:Microsoft.PowerShell.Utility.Set-Variable)-
Microsoft.PowerShell.Core About Split (7.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.1/Microsoft.PowerShell.Core/About/about_Split.md
---
-description: Explains how to use the Split operator to split one or more strings into substrings.
-keywords: powershell,cmdlet
+description: Explains how to use the Split operator to split one or more strings into substrings.
Locale: en-US Previously updated : 03/24/2020 Last updated : 03/30/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_split?view=powershell-7.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about_Split
whitespace, including spaces and non-printable characters, such as newline
(\`n) and tab (\`t). When the strings are split, the delimiter is omitted from all the substrings. Example:
-```
+```powershell
"Lastname:FirstName:Address" -split ":" Lastname FirstName
Address
By default, the delimiter is omitted from the results. To preserve all or part of the delimiter, enclose in parentheses the part that you want to preserve.
-If the \<Max-substrings\> parameter is added, this takes precedence when your
+If the `<Max-substrings>` parameter is added, this takes precedence when your
command splits up the collection. If you opt to include a delimiter as part of the output, the command returns the delimiter as part of the output; however, splitting the string to return the delimiter as part of output does not count
as a split.
Examples:
-```
+```powershell
"Lastname:FirstName:Address" -split "(:)" Lastname :
FirstName
Address ```
-In the following example, \<Max-substrings\> is set to 3. This results in
-three splits of the string values, but a total of five strings in the
-resulting output; the delimiter is included after the splits, until the
+### `<Max-substrings>`
+
+Specifies the maximum number of substrings returned by the split operation. The
+default is all substrings split by the delimiter. If there are more
+substrings, they are concatenated to the final substring. If there are fewer
+substrings, all substrings are returned. A value of 0 returns all the
+substrings.
+
+Example:
+
+```powershell
+$c = "Mercury,Venus,Earth,Mars,Jupiter,Saturn,Uranus,Neptune"
+$c -split ",", 5
+```
+
+```Output
+Mercury
+Venus
+Earth
+Mars
+Jupiter,Saturn,Uranus,Neptune
+```
+
+If you submit more than one string (an array of strings) to the `-split`
+operator, the `Max-substrings` limit is applied to each string separately.
+
+```powershell
+$c = 'a,b,c','1,2,3,4,5'
+$c -split ',', 3
+
+a
+b
+c
+1
+2
+3,4,5
+```
+
+`<Max-substrings>` does not specify the maximum number of objects that are
+returned. In the following example, `<Max-substrings>` is set to 3.
+This results in three substring values, but a total of five strings
+in the resulting output. The delimiter is included after the splits until the
maximum of three substrings is reached. Additional delimiters in the final substring become part of the substring.
Vanilla
Strawberry-Blueberry ```
-### \<Max-substrings\>
-
-Specifies the maximum number of times that a string is split. The default is
-all the substrings split by the delimiter. If there are more substrings, they
-are concatenated to the final substring. If there are fewer substrings, all
-the substrings are returned. A value of 0 returns all the substrings. Negative
-values return the amount of substrings requested starting from the end of the
-input string.
+Negative values return the amount of substrings requested starting
+from the end of the input string.
> [!NOTE] > Support for negative values was added in PowerShell 7.
-**Max-substrings** does not specify the maximum number of objects that are
-returned. Its value equals the maximum number of times that a string is split.
-If you submit more than one string (an array of strings) to the `-split`
-operator, the **Max-substrings** limit is applied to each string separately.
-
-Example:
-
-```powershell
-$c = "Mercury,Venus,Earth,Mars,Jupiter,Saturn,Uranus,Neptune"
-$c -split ",", 5
-```
-
-```Output
-Mercury
-Venus
-Earth
-Mars
-Jupiter,Saturn,Uranus,Neptune
-```
- ```powershell $c = "Mercury,Venus,Earth,Mars,Jupiter,Saturn,Uranus,Neptune" $c -split ",", -5
LastName, FirstName
[about_Comparison_Operators](about_Comparison_Operators.md) [about_Join](about_Join.md)-
Microsoft.PowerShell.Core About Variables (7.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.1/Microsoft.PowerShell.Core/About/about_Variables.md
---
-description: Describes how variables store values that can be used in PowerShell.
-keywords: powershell,cmdlet
+description: Describes how variables store values that can be used in PowerShell.
Locale: en-US Previously updated : 11/09/2020 Last updated : 03/30/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_variables?view=powershell-7.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about_Variables
Remove-Variable -Name MyVariable
Remove-Item -Path Variable:\MyVariable ```
+It is also possible to values to multiple variables with one statement. The
+following examples assigns the same value to multiple variables:
+
+```powershell
+$a = $b = $c = 0
+```
+
+The next example assigns multiple values to multiple variables.
+
+```powershell
+$i,$j,$k = 10, "red", $true # $i is 10, $j is "red", $k is True
+$i,$j = 10, "red", $true # $i is 10, $j is [object[]], Length 2
+```
+
+For more detailed information, see the **Assigning multiple variables** section
+of [about_Assignment_Operators](about_assignment_operators.md#assigning-multiple-variables).
+ ## Types of variables You can store any type of object in a variable, including integers, strings,
Get-Help <cmdlet-name>
[about_Scopes](about_Scopes.md) [about_Remote_Variables](about_Remote_Variables.md)-
Microsoft.PowerShell.Utility New Variable (7.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.1/Microsoft.PowerShell.Utility/New-Variable.md
external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml
keywords: powershell,cmdlet Locale: en-US Module Name: Microsoft.PowerShell.Utility Previously updated : 06/09/2017 Last updated : 03/30/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/new-variable?view=powershell-7.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: New-Variable
Title: New-Variable
# New-Variable
-## SYNOPSIS
+## Synopsis
Creates a new variable.
-## SYNTAX
+## Syntax
``` New-Variable [-Name] <String> [[-Value] <Object>] [-Description <String>] [-Option <ScopedItemOptions>]
New-Variable [-Name] <String> [[-Value] <Object>] [-Description <String>] [-Opti
[<CommonParameters>] ```
-## DESCRIPTION
-The **New-Variable** cmdlet creates a new variable in PowerShell.
-You can assign a value to the variable while creating it or assign or change the value after it is created.
+## Description
-You can use the parameters of **New-Variable** to set the properties of the variable, set the scope of a variable, and determine whether variables are public or private.
+The `New-Variable` cmdlet creates a new variable in Windows PowerShell. You can assign a value to
+the variable while creating it or assign or change the value after it is created.
-Typically, you create a new variable by typing the variable name and its value, such as `$Var = 3`, but you can use the **New-Variable** cmdlet to use its parameters.
+You can use the parameters of `New-Variable` to set the properties of the variable, set the scope of
+a variable, and determine whether variables are public or private.
-## EXAMPLES
+Typically, you create a new variable by typing the variable name and its value, such as `$Var = 3`,
+but you can use the `New-Variable` cmdlet to use its parameters.
+
+## Examples
### Example 1: Create a variable ```
-PS C:\> New-Variable days
+New-Variable days
```
-This command creates a new variable named days.
-You are not required to type the *Name* parameter.
+This command creates a new variable named days. You are not required to type the **Name** parameter.
### Example 2: Create a variable and assign it a value ```
-PS C:\> New-Variable -Name "zipcode" -Value 98033
+New-Variable -Name "zipcode" -Value 98033
``` This command creates a variable named zipcode and assigns it the value 98033.
At line:1 char:1
PS C:\> New-Variable -Name max -Value 1024 -Force ```
-This example shows how to use the ReadOnly option of **New-Variable** to protect a variable from being overwritten.
+This example shows how to use the `ReadOnly` option of `New-Variable` to protect a variable from
+being overwritten.
-The first command creates a new variable named Max and sets its value to 256.
-It uses the *Option* parameter with a value of ReadOnly.
+The first command creates a new variable named Max and sets its value to 256. It uses the **Option**
+parameter with a value of `ReadOnly`.
-The second command tries to create a second variable with the same name.
-This command returns an error, because the read-only option is set on the variable.
+The second command tries to create a second variable with the same name. This command returns an
+error, because the read-only option is set on the variable.
-The third command uses the *Force* parameter to override the read-only protection on the variable.
+The third command uses the **Force** parameter to override the read-only protection on the variable.
In this case, the command to create a new variable with the same name succeeds.
-### Example 4: Create a private variable
+### Example 4: Assign multiple options to a variable
+
+```powershell
+New-Variable -Name 'TestVariable' -Value 'Test Value' -Option AllScope,Constant
+```
+
+This example creates a variable and assigns the `AllScope` and `Constant` options so the variable
+will be available in the current scope and any new scopes created and cannot be changed or deleted.
+
+### Example 5: Create a private variable
``` PS C:\> New-Variable -Name counter -Visibility Private
Counter1 3.1415
... ```
-This command demonstrates the behavior of a private variable in a module.
-The module contains the Get-Counter cmdlet, which has a private variable named Counter.
-The command uses the *Visibility* parameter with a value of Private to create the variable.
+This command demonstrates the behavior of a private variable in a module. The module contains the
+`Get-Counter` cmdlet, which has a private variable named Counter. The command uses the
+**Visibility** parameter with a value of Private to create the variable.
-The sample output shows the behavior of a private variable.
-The user who has loaded the module cannot view or change the value of the Counter variable, but the Counter variable can be read and changed by the commands in the module.
+The sample output shows the behavior of a private variable. The user who has loaded the module
+cannot view or change the value of the Counter variable, but the Counter variable can be read and
+changed by the commands in the module.
-### Example 5: Create a variable with a space
+### Example 6: Create a variable with a space
``` PS C:\> New-Variable -Name 'with space' -Value 'abc123xyz'
PS C:\> ${with space}
abc123xyz ```
-This command demonstrates that variables with spaces can be created.
-The variables can be accessed using the **Get-Variable** cmdlet or directly by delimiting a variable with braces.
+This command demonstrates that variables with spaces can be created. The variables can be accessed
+using the `Get-Variable` cmdlet or directly by delimiting a variable with braces.
-## PARAMETERS
+## Parameters
### -Description+ Specifies a description of the variable. ```yaml
Accept wildcard characters: False
``` ### -Force+ Indicates that the cmdlet creates a variable with the same name as an existing read-only variable.
-By default, you can overwrite a variable unless the variable has an option value of ReadOnly or Constant.
-For more information, see the *Option* parameter.
+By default, you can overwrite a variable unless the variable has an option value of `ReadOnly` or
+`Constant`. For more information, see the **Option** parameter.
```yaml Type: System.Management.Automation.SwitchParameter
Accept wildcard characters: False
``` ### -Name+ Specifies a name for the new variable. ```yaml
Accept wildcard characters: False
``` ### -Option
-Specifies the value of the **Options** property of the variable.The acceptable values for this parameter are:
--- None.
-Sets no options.
-(None is the default.)
-- ReadOnly.
-Can be deleted.
-Cannot be changed, except by using the *Force* parameter.
-- Private.
-The variable is available only in the current scope.
-- AllScope.
-The variable is copied to any new scopes that are created.
-- Constant.
-Cannot be deleted or changed.
-Constant is valid only when you are creating a variable.
-You cannot change the options of an existing variable to Constant.
-
-To see the **Options** property of all variables in the session, type `Get-Variable | Format-Table -Property name, options -autosize`.
+
+Specifies the value of the **Options** property of the variable. The acceptable values for this
+parameter are:
+
+- `None` - Sets no options. `None` is the default.
+- `ReadOnly` - Can be deleted. Cannot be changed, except by using the **Force** parameter.
+- `Private` - The variable is available only in the current scope.
+- `AllScope` - The variable is copied to any new scopes that are created.
+- `Constant` - Cannot be deleted or changed. `Constant` is valid only when you are creating a
+ variable. You cannot change the options of an existing variable to `Constant`.
+
+These values are defined as a flag-based enumeration. You can combine multiple values together to
+set multiple flags using this parameter. The values can be passed to the **Option** parameter as an
+array of values or as a comma-separated string of those values. The cmdlet will combine the values
+using a binary-OR operation. Passing values as an array is the simplest option and also allows you
+to use tab-completion on the values.
+
+To see the Options property of all variables in the session, type
+`Get-Variable | Format-Table -Property name, options -AutoSize`.
```yaml Type: System.Management.Automation.ScopedItemOptions
Accept wildcard characters: False
``` ### -PassThru
-Returns an object representing the item with which you are working.
-By default, this cmdlet does not generate any output.
+
+Returns an object representing the item with which you are working. By default, this cmdlet does not
+generate any output.
```yaml Type: System.Management.Automation.SwitchParameter
Accept wildcard characters: False
``` ### -Scope
-Specifies the scope of the new variable.
-The acceptable values for this parameter are:
-- Global.
-Variables created in the global scope are accessible everywhere in a PowerShell process.
-- Local.
-The local scope refers to the current scope, this can be any scope depending on the context.
-- Script.
-Variables created in the script scope are accessible only within the script file or module they are created in.
-- Private.
-Variables created in the private scope cannot be accessed outside the scope they exist in.
-You can use private scope to create a private version of an item with the same name in another scope.
-- A number relative to the current scope (0 through the number of scopes, where 0 is the current scope, 1 is its parent, 2 the parent of the parent scope, and so on).
-Negative numbers cannot be used.
+Specifies the scope of the new variable. The acceptable values for this parameter are:
+
+- `Global` - Variables created in the global scope are accessible everywhere in a PowerShell
+ process.
+- `Local` - The local scope refers to the current scope, this can be any scope depending on the
+ context.
+- `Script` - Variables created in the script scope are accessible only within the script file or
+ module they are created in.
+- `Private` - Variables created in the private scope cannot be accessed outside the scope they exist
+ in. You can use private scope to create a private version of an item with the same name in another
+ scope.
+- A number relative to the current scope (0 through the number of scopes, where 0 is the current
+ scope, 1 is its parent, 2 the parent of the parent scope, and so on). Negative numbers cannot be
+ used.
-Local is the default scope when the scope parameter is not specified.
+`Local` is the default scope when the scope parameter is not specified.
-For more information, see about_Scopes.
+For more information, see [about_Scopes](../Microsoft.PowerShell.Core/About/about_Scopes.md).
```yaml Type: System.String
Accept wildcard characters: False
``` ### -Value+ Specifies the initial value of the variable. ```yaml
Accept wildcard characters: False
``` ### -Visibility
-Determines whether the variable is visible outside of the session in which it was created.
-This parameter is designed for use in scripts and commands that will be delivered to other users.
-The acceptable values for this parameter are:
-- Public.
-The variable is visible.
-(Public is the default.)
-- Private.
-The variable is not visible.
+Determines whether the variable is visible outside of the session in which it was created. This
+parameter is designed for use in scripts and commands that will be delivered to other users. The
+acceptable values for this parameter are:
+
+- `Public` - The variable is visible. `Public` is the default.
+- `Private` - The variable is not visible.
-When a variable is private, it does not appear in lists of variables, such as those returned by Get-Variable, or in displays of the Variable: drive.
-Commands to read or change the value of a private variable return an error.
-However, the user can run commands that use a private variable if the commands were written in the session in which the variable was defined.
+When a variable is private, it does not appear in lists of variables, such as those returned by
+`Get-Variable`, or in displays of the `Variable:` drive. Commands to read or change the value of a
+private variable return an error. However, the user can run commands that use a private variable if
+the commands were written in the session in which the variable was defined.
```yaml Type: System.Management.Automation.SessionStateEntryVisibility
Accept wildcard characters: False
``` ### -Confirm+ Prompts you for confirmation before running the cmdlet. ```yaml
Accept wildcard characters: False
``` ### -WhatIf
-Shows what would happen if the cmdlet runs.
-The cmdlet is not run.
+
+Shows what would happen if the cmdlet runs. The cmdlet is not run.
```yaml Type: System.Management.Automation.SwitchParameter
Accept wildcard characters: False
``` ### CommonParameters+ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
-## INPUTS
+## Inputs
### System.Object
-You can pipe a value to **New-Variable**.
-## OUTPUTS
+You can pipe a value to `New-Variable`.
+
+## Outputs
### None or System.Management.Automation.PSVariable
-When you use the *PassThru* parameter, **New-Variable** generates a **System.Management.Automation.PSVariable** object representing the new variable.
-Otherwise, this cmdlet does not generate any output.
-## NOTES
+When you use the **PassThru** parameter, `New-Variable` generates a
+**System.Management.Automation.PSVariable** object representing the new variable. Otherwise, this
+cmdlet does not generate any output.
-## RELATED LINKS
+## Notes
+
+## Related Links
[Clear-Variable](Clear-Variable.md)
Otherwise, this cmdlet does not generate any output.
[Remove-Variable](Remove-Variable.md) [Set-Variable](Set-Variable.md)-
Microsoft.PowerShell.Core About Assignment Operators (7.2) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.2/Microsoft.PowerShell.Core/About/about_Assignment_Operators.md
--- description: Describes how to use operators to assign values to variables. Locale: en-US Previously updated : 04/26/2020 Last updated : 03/30/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_assignment_operators?view=powershell-7.2&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about_Assignment_Operators
Tuesday, May 31, 2005 12:00:00 AM
In PowerShell, you can assign values to multiple variables by using a single command. The first element of the assignment value is assigned to the first variable, the second element is assigned to the second variable, the third
-element to the third variable, and so on. For example, the following command
-assigns the value 1 to the `$a` variable, the value 2 to the `$b` variable, and
-the value 3 to the `$c` variable:
+element to the third variable, and so on. This is known as _multiple
+assignment_.
+
+For example, the following command assigns the value 1 to the `$a` variable,
+the value 2 to the `$b` variable, and the value 3 to the `$c` variable:
```powershell $a, $b, $c = 1, 2, 3
$d, $e, $f = $c
This command assigns the value 3 to the `$d` variable, the value 4 to the `$e` variable, and the value 5 to the `$f` variable.
-If the assignment value contains less elements than variables, all the
-remaining variables at the end are not assigned any values. For example, the
+If the assignment value contains fewer elements than variables, the
+remaining variables are assigned the value `$null`. For example, the
following command contains three variables and two values: ```powershell
$a, $b, $c = 1, 2
``` Therefore, PowerShell assigns the value 1 to the `$a` variable and the value 2
-to the `$b` variable. It will not assign any value to the `$c` variable.
+to the `$b` variable. The `$c` variable is `$null`.
You can also assign a single value to multiple variables by chaining the variables. For example, the following command assigns a value of "three" to all
Set-Variable -Name a -Value 1, 2, 3
[Remove-Variable](xref:Microsoft.PowerShell.Utility.Remove-Variable) [Set-Variable](xref:Microsoft.PowerShell.Utility.Set-Variable)-
Microsoft.PowerShell.Core About Split (7.2) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.2/Microsoft.PowerShell.Core/About/about_Split.md
--- description: Explains how to use the Split operator to split one or more strings into substrings. Locale: en-US Previously updated : 03/24/2020 Last updated : 03/30/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_split?view=powershell-7.2&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about_Split
whitespace, including spaces and non-printable characters, such as newline
(\`n) and tab (\`t). When the strings are split, the delimiter is omitted from all the substrings. Example:
-```
+```powershell
"Lastname:FirstName:Address" -split ":" Lastname FirstName
Address
By default, the delimiter is omitted from the results. To preserve all or part of the delimiter, enclose in parentheses the part that you want to preserve.
-If the \<Max-substrings\> parameter is added, this takes precedence when your
+If the `<Max-substrings>` parameter is added, this takes precedence when your
command splits up the collection. If you opt to include a delimiter as part of the output, the command returns the delimiter as part of the output; however, splitting the string to return the delimiter as part of output does not count
as a split.
Examples:
-```
+```powershell
"Lastname:FirstName:Address" -split "(:)" Lastname :
FirstName
Address ```
-In the following example, \<Max-substrings\> is set to 3. This results in
-three splits of the string values, but a total of five strings in the
-resulting output; the delimiter is included after the splits, until the
+### `<Max-substrings>`
+
+Specifies the maximum number of substrings returned by the split operation. The
+default is all substrings split by the delimiter. If there are more
+substrings, they are concatenated to the final substring. If there are fewer
+substrings, all substrings are returned. A value of 0 returns all the
+substrings.
+
+Example:
+
+```powershell
+$c = "Mercury,Venus,Earth,Mars,Jupiter,Saturn,Uranus,Neptune"
+$c -split ",", 5
+```
+
+```Output
+Mercury
+Venus
+Earth
+Mars
+Jupiter,Saturn,Uranus,Neptune
+```
+
+If you submit more than one string (an array of strings) to the `-split`
+operator, the `Max-substrings` limit is applied to each string separately.
+
+```powershell
+$c = 'a,b,c','1,2,3,4,5'
+$c -split ',', 3
+
+a
+b
+c
+1
+2
+3,4,5
+```
+
+`<Max-substrings>` does not specify the maximum number of objects that are
+returned. In the following example, `<Max-substrings>` is set to 3.
+This results in three substring values, but a total of five strings
+in the resulting output. The delimiter is included after the splits until the
maximum of three substrings is reached. Additional delimiters in the final substring become part of the substring.
Vanilla
Strawberry-Blueberry ```
-### \<Max-substrings\>
-
-Specifies the maximum number of times that a string is split. The default is
-all the substrings split by the delimiter. If there are more substrings, they
-are concatenated to the final substring. If there are fewer substrings, all
-the substrings are returned. A value of 0 returns all the substrings. Negative
-values return the amount of substrings requested starting from the end of the
-input string.
+Negative values return the amount of substrings requested starting
+from the end of the input string.
> [!NOTE] > Support for negative values was added in PowerShell 7.
-**Max-substrings** does not specify the maximum number of objects that are
-returned. Its value equals the maximum number of times that a string is split.
-If you submit more than one string (an array of strings) to the `-split`
-operator, the **Max-substrings** limit is applied to each string separately.
-
-Example:
-
-```powershell
-$c = "Mercury,Venus,Earth,Mars,Jupiter,Saturn,Uranus,Neptune"
-$c -split ",", 5
-```
-
-```Output
-Mercury
-Venus
-Earth
-Mars
-Jupiter,Saturn,Uranus,Neptune
-```
- ```powershell $c = "Mercury,Venus,Earth,Mars,Jupiter,Saturn,Uranus,Neptune" $c -split ",", -5
LastName, FirstName
[about_Comparison_Operators](about_Comparison_Operators.md) [about_Join](about_Join.md)-
Microsoft.PowerShell.Core About Variables (7.2) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.2/Microsoft.PowerShell.Core/About/about_Variables.md
--- description: Describes how variables store values that can be used in PowerShell. Locale: en-US Previously updated : 11/09/2020 Last updated : 03/30/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_variables?view=powershell-7.2&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about_Variables
Remove-Variable -Name MyVariable
Remove-Item -Path Variable:\MyVariable ```
+It is also possible to values to multiple variables with one statement. The
+following examples assigns the same value to multiple variables:
+
+```powershell
+$a = $b = $c = 0
+```
+
+The next example assigns multiple values to multiple variables.
+
+```powershell
+$i,$j,$k = 10, "red", $true # $i is 10, $j is "red", $k is True
+$i,$j = 10, "red", $true # $i is 10, $j is [object[]], Length 2
+```
+
+For more detailed information, see the **Assigning multiple variables** section
+of [about_Assignment_Operators](about_assignment_operators.md#assigning-multiple-variables).
+ ## Types of variables You can store any type of object in a variable, including integers, strings,
Get-Help <cmdlet-name>
[about_Scopes](about_Scopes.md) [about_Remote_Variables](about_Remote_Variables.md)-
Microsoft.PowerShell.Utility New Variable (7.2) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.2/Microsoft.PowerShell.Utility/New-Variable.md
external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Utility Previously updated : 06/09/2017 Last updated : 03/30/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/new-variable?view=powershell-7.2&WT.mc_id=ps-gethelp schema: 2.0.0 Title: New-Variable
Title: New-Variable
# New-Variable
-## SYNOPSIS
+## Synopsis
Creates a new variable.
-## SYNTAX
+## Syntax
``` New-Variable [-Name] <String> [[-Value] <Object>] [-Description <String>] [-Option <ScopedItemOptions>]
New-Variable [-Name] <String> [[-Value] <Object>] [-Description <String>] [-Opti
[<CommonParameters>] ```
-## DESCRIPTION
-The **New-Variable** cmdlet creates a new variable in PowerShell.
-You can assign a value to the variable while creating it or assign or change the value after it is created.
+## Description
-You can use the parameters of **New-Variable** to set the properties of the variable, set the scope of a variable, and determine whether variables are public or private.
+The `New-Variable` cmdlet creates a new variable in Windows PowerShell. You can assign a value to
+the variable while creating it or assign or change the value after it is created.
-Typically, you create a new variable by typing the variable name and its value, such as `$Var = 3`, but you can use the **New-Variable** cmdlet to use its parameters.
+You can use the parameters of `New-Variable` to set the properties of the variable, set the scope of
+a variable, and determine whether variables are public or private.
-## EXAMPLES
+Typically, you create a new variable by typing the variable name and its value, such as `$Var = 3`,
+but you can use the `New-Variable` cmdlet to use its parameters.
+
+## Examples
### Example 1: Create a variable ```
-PS C:\> New-Variable days
+New-Variable days
```
-This command creates a new variable named days.
-You are not required to type the *Name* parameter.
+This command creates a new variable named days. You are not required to type the **Name** parameter.
### Example 2: Create a variable and assign it a value ```
-PS C:\> New-Variable -Name "zipcode" -Value 98033
+New-Variable -Name "zipcode" -Value 98033
``` This command creates a variable named zipcode and assigns it the value 98033.
At line:1 char:1
PS C:\> New-Variable -Name max -Value 1024 -Force ```
-This example shows how to use the ReadOnly option of **New-Variable** to protect a variable from being overwritten.
+This example shows how to use the `ReadOnly` option of `New-Variable` to protect a variable from
+being overwritten.
-The first command creates a new variable named Max and sets its value to 256.
-It uses the *Option* parameter with a value of ReadOnly.
+The first command creates a new variable named Max and sets its value to 256. It uses the **Option**
+parameter with a value of `ReadOnly`.
-The second command tries to create a second variable with the same name.
-This command returns an error, because the read-only option is set on the variable.
+The second command tries to create a second variable with the same name. This command returns an
+error, because the read-only option is set on the variable.
-The third command uses the *Force* parameter to override the read-only protection on the variable.
+The third command uses the **Force** parameter to override the read-only protection on the variable.
In this case, the command to create a new variable with the same name succeeds.
-### Example 4: Create a private variable
+### Example 4: Assign multiple options to a variable
+
+```powershell
+New-Variable -Name 'TestVariable' -Value 'Test Value' -Option AllScope,Constant
+```
+
+This example creates a variable and assigns the `AllScope` and `Constant` options so the variable
+will be available in the current scope and any new scopes created and cannot be changed or deleted.
+
+### Example 5: Create a private variable
``` PS C:\> New-Variable -Name counter -Visibility Private
Counter1 3.1415
... ```
-This command demonstrates the behavior of a private variable in a module.
-The module contains the Get-Counter cmdlet, which has a private variable named Counter.
-The command uses the *Visibility* parameter with a value of Private to create the variable.
+This command demonstrates the behavior of a private variable in a module. The module contains the
+`Get-Counter` cmdlet, which has a private variable named Counter. The command uses the
+**Visibility** parameter with a value of Private to create the variable.
-The sample output shows the behavior of a private variable.
-The user who has loaded the module cannot view or change the value of the Counter variable, but the Counter variable can be read and changed by the commands in the module.
+The sample output shows the behavior of a private variable. The user who has loaded the module
+cannot view or change the value of the Counter variable, but the Counter variable can be read and
+changed by the commands in the module.
-### Example 5: Create a variable with a space
+### Example 6: Create a variable with a space
``` PS C:\> New-Variable -Name 'with space' -Value 'abc123xyz'
PS C:\> ${with space}
abc123xyz ```
-This command demonstrates that variables with spaces can be created.
-The variables can be accessed using the **Get-Variable** cmdlet or directly by delimiting a variable with braces.
+This command demonstrates that variables with spaces can be created. The variables can be accessed
+using the `Get-Variable` cmdlet or directly by delimiting a variable with braces.
-## PARAMETERS
+## Parameters
### -Description+ Specifies a description of the variable. ```yaml
Accept wildcard characters: False
``` ### -Force+ Indicates that the cmdlet creates a variable with the same name as an existing read-only variable.
-By default, you can overwrite a variable unless the variable has an option value of ReadOnly or Constant.
-For more information, see the *Option* parameter.
+By default, you can overwrite a variable unless the variable has an option value of `ReadOnly` or
+`Constant`. For more information, see the **Option** parameter.
```yaml Type: System.Management.Automation.SwitchParameter
Accept wildcard characters: False
``` ### -Name+ Specifies a name for the new variable. ```yaml
Accept wildcard characters: False
``` ### -Option
-Specifies the value of the **Options** property of the variable.The acceptable values for this parameter are:
--- None.
-Sets no options.
-(None is the default.)
-- ReadOnly.
-Can be deleted.
-Cannot be changed, except by using the *Force* parameter.
-- Private.
-The variable is available only in the current scope.
-- AllScope.
-The variable is copied to any new scopes that are created.
-- Constant.
-Cannot be deleted or changed.
-Constant is valid only when you are creating a variable.
-You cannot change the options of an existing variable to Constant.
-
-To see the **Options** property of all variables in the session, type `Get-Variable | Format-Table -Property name, options -autosize`.
+
+Specifies the value of the **Options** property of the variable. The acceptable values for this
+parameter are:
+
+- `None` - Sets no options. `None` is the default.
+- `ReadOnly` - Can be deleted. Cannot be changed, except by using the **Force** parameter.
+- `Private` - The variable is available only in the current scope.
+- `AllScope` - The variable is copied to any new scopes that are created.
+- `Constant` - Cannot be deleted or changed. `Constant` is valid only when you are creating a
+ variable. You cannot change the options of an existing variable to `Constant`.
+
+These values are defined as a flag-based enumeration. You can combine multiple values together to
+set multiple flags using this parameter. The values can be passed to the **Option** parameter as an
+array of values or as a comma-separated string of those values. The cmdlet will combine the values
+using a binary-OR operation. Passing values as an array is the simplest option and also allows you
+to use tab-completion on the values.
+
+To see the Options property of all variables in the session, type
+`Get-Variable | Format-Table -Property name, options -AutoSize`.
```yaml Type: System.Management.Automation.ScopedItemOptions
Accept wildcard characters: False
``` ### -PassThru
-Returns an object representing the item with which you are working.
-By default, this cmdlet does not generate any output.
+
+Returns an object representing the item with which you are working. By default, this cmdlet does not
+generate any output.
```yaml Type: System.Management.Automation.SwitchParameter
Accept wildcard characters: False
``` ### -Scope
-Specifies the scope of the new variable.
-The acceptable values for this parameter are:
-- Global.
-Variables created in the global scope are accessible everywhere in a PowerShell process.
-- Local.
-The local scope refers to the current scope, this can be any scope depending on the context.
-- Script.
-Variables created in the script scope are accessible only within the script file or module they are created in.
-- Private.
-Variables created in the private scope cannot be accessed outside the scope they exist in.
-You can use private scope to create a private version of an item with the same name in another scope.
-- A number relative to the current scope (0 through the number of scopes, where 0 is the current scope, 1 is its parent, 2 the parent of the parent scope, and so on).
-Negative numbers cannot be used.
+Specifies the scope of the new variable. The acceptable values for this parameter are:
+
+- `Global` - Variables created in the global scope are accessible everywhere in a PowerShell
+ process.
+- `Local` - The local scope refers to the current scope, this can be any scope depending on the
+ context.
+- `Script` - Variables created in the script scope are accessible only within the script file or
+ module they are created in.
+- `Private` - Variables created in the private scope cannot be accessed outside the scope they exist
+ in. You can use private scope to create a private version of an item with the same name in another
+ scope.
+- A number relative to the current scope (0 through the number of scopes, where 0 is the current
+ scope, 1 is its parent, 2 the parent of the parent scope, and so on). Negative numbers cannot be
+ used.
-Local is the default scope when the scope parameter is not specified.
+`Local` is the default scope when the scope parameter is not specified.
-For more information, see about_Scopes.
+For more information, see [about_Scopes](../Microsoft.PowerShell.Core/About/about_Scopes.md).
```yaml Type: System.String
Accept wildcard characters: False
``` ### -Value+ Specifies the initial value of the variable. ```yaml
Accept wildcard characters: False
``` ### -Visibility
-Determines whether the variable is visible outside of the session in which it was created.
-This parameter is designed for use in scripts and commands that will be delivered to other users.
-The acceptable values for this parameter are:
-- Public.
-The variable is visible.
-(Public is the default.)
-- Private.
-The variable is not visible.
+Determines whether the variable is visible outside of the session in which it was created. This
+parameter is designed for use in scripts and commands that will be delivered to other users. The
+acceptable values for this parameter are:
+
+- `Public` - The variable is visible. `Public` is the default.
+- `Private` - The variable is not visible.
-When a variable is private, it does not appear in lists of variables, such as those returned by Get-Variable, or in displays of the Variable: drive.
-Commands to read or change the value of a private variable return an error.
-However, the user can run commands that use a private variable if the commands were written in the session in which the variable was defined.
+When a variable is private, it does not appear in lists of variables, such as those returned by
+`Get-Variable`, or in displays of the `Variable:` drive. Commands to read or change the value of a
+private variable return an error. However, the user can run commands that use a private variable if
+the commands were written in the session in which the variable was defined.
```yaml Type: System.Management.Automation.SessionStateEntryVisibility
Accept wildcard characters: False
``` ### -Confirm+ Prompts you for confirmation before running the cmdlet. ```yaml
Accept wildcard characters: False
``` ### -WhatIf
-Shows what would happen if the cmdlet runs.
-The cmdlet is not run.
+
+Shows what would happen if the cmdlet runs. The cmdlet is not run.
```yaml Type: System.Management.Automation.SwitchParameter
Accept wildcard characters: False
``` ### CommonParameters+ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
-## INPUTS
+## Inputs
### System.Object
-You can pipe a value to **New-Variable**.
-## OUTPUTS
+You can pipe a value to `New-Variable`.
+
+## Outputs
### None or System.Management.Automation.PSVariable
-When you use the *PassThru* parameter, **New-Variable** generates a **System.Management.Automation.PSVariable** object representing the new variable.
-Otherwise, this cmdlet does not generate any output.
-## NOTES
+When you use the **PassThru** parameter, `New-Variable` generates a
+**System.Management.Automation.PSVariable** object representing the new variable. Otherwise, this
+cmdlet does not generate any output.
-## RELATED LINKS
+## Notes
+
+## Related Links
[Clear-Variable](Clear-Variable.md)
Otherwise, this cmdlet does not generate any output.
[Remove-Variable](Remove-Variable.md) [Set-Variable](Set-Variable.md)-
community 2020 Updates https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/docs-conceptual/community/2020-updates.md
--- Title: What's New in PowerShell Docs for 2020-Q4
-description: List of changes to the PowerShell documentation for Q4 of 2020
+ Title: What's New in PowerShell Docs for 2020
+description: List of changes to the PowerShell documentation for 2020
Last updated 01/05/2021 ---
community 2021 Updates https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/docs-conceptual/community/2021-updates.md
--- Title: What's New in PowerShell Docs for 2020-Q1
-description: List of changes to the PowerShell documentation for 2020-Q1
+ Title: What's New in PowerShell Docs for 2021
+description: List of changes to the PowerShell documentation for 2021
Last updated 03/02/2021 ---
install Installing Powershell Core On Windows https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/docs-conceptual/install/Installing-PowerShell-Core-on-Windows.md
--- Title: Installing PowerShell on Windows description: Information about installing PowerShell on Windows Previously updated : 02/02/2021 Last updated : 03/30/2021 --- # Installing PowerShell on Windows
as a [.NET Global tool](/dotnet/core/tools/global-tools).
dotnet tool install --global PowerShell ```
-The dotnet tool installer adds `$env:USERPROFILE\dotnet\tools` to your `$env:PATH` environment
+The dotnet tool installer adds `$env:USERPROFILE\.dotnet\tools` to your `$env:PATH` environment
variable. However, the currently running shell doesn't have the updated `$env:PATH`. You can start PowerShell from a new shell by typing `pwsh`.
learn Everything About Arrays https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/docs-conceptual/learn/deep-dives/everything-about-arrays.md
TypeName: System.String
... ```
-To prevent that unwrap of the array, you can use `Write-Object -NoEnumerate`.
+To prevent that unwrap of the array, you can use `Write-Output -NoEnumerate`.
```powershell PS> Write-Output -NoEnumerate $data | Get-Member