Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,27 @@ The aliases have no child items.
The **Alias** provider supports the following cmdlets, which are covered
in this article.

- [Get-Location](xref:Microsoft.PowerShell.Management.Get-Location)
- [Set-Location](xref:Microsoft.PowerShell.Management.Set-Location)
- [Get-Item](xref:Microsoft.PowerShell.Management.Get-Item)
- [New-Item](xref:Microsoft.PowerShell.Management.New-Item)
- [Remove-Item](xref:Microsoft.PowerShell.Management.Remove-Item)
- [Clear-Item](xref:Microsoft.PowerShell.Management.Clear-Item)
- [Get-Location][01]
- [Set-Location][02]
- [Get-Item][03]
- [New-Item][04]
- [Remove-Item][05]
- [Clear-Item][06]

PowerShell includes a set of cmdlets that are designed to view and to change
aliases. When you use **Alias** cmdlets, you do not need to specify the
`Alias:` drive in the name. This article does not cover working with **Alias**
cmdlets.

- [Export-Alias](xref:Microsoft.PowerShell.Utility.Export-Alias)
- [Get-Alias](xref:Microsoft.PowerShell.Utility.Get-Alias)
- [Import-Alias](xref:Microsoft.PowerShell.Utility.Import-Alias)
- [New-Alias](xref:Microsoft.PowerShell.Utility.New-Alias)
- [Set-Alias](xref:Microsoft.PowerShell.Utility.Set-Alias)
- [Export-Alias][07]
- [Get-Alias][08]
- [Import-Alias][09]
- [New-Alias][10]
- [Set-Alias][11]

## Types exposed by this provider

Each alias is an instance of the
[System.Management.Automation.AliasInfo](/dotnet/api/system.management.automation.aliasinfo)
Each alias is an instance of the [System.Management.Automation.AliasInfo][12]
class.

## Navigating the Alias drive
Expand All @@ -87,11 +86,8 @@ path.
> [!NOTE]
> PowerShell uses aliases to allow you a familiar way to work with provider
> paths. Commands such as `dir` and `ls` are now aliases for
> [Get-ChildItem](xref:Microsoft.PowerShell.Management.Get-ChildItem), `cd` is
> an alias for
> [Set-Location](xref:Microsoft.PowerShell.Management.Set-Location). and `pwd`
> is an alias for
> [Get-Location](xref:Microsoft.PowerShell.Management.Get-Location).
> [Get-ChildItem][13], `cd` is an alias for [Set-Location][02], and `pwd` is an
> alias for [Get-Location][01].

### Displaying the Contents of the Alias: drive

Expand Down Expand Up @@ -198,7 +194,7 @@ cmdlet. The `-Options` parameter is available in `Set-Item` when you use it
with the **Alias** or **Function** provider.

```powershell
Set-Item -Path Alias:dir -Options "AllScope,ReadOnly"
Set-Item -Path Alias:dir -Options "AllScope, ReadOnly"
```

### Change an aliases referenced command
Expand Down Expand Up @@ -293,8 +289,8 @@ Determines the value of the **Options** property of an alias.

#### Cmdlets supported

- [New-Item](xref:Microsoft.PowerShell.Management.New-Item)
- [Set-Item](xref:Microsoft.PowerShell.Management.Set-Item)
- [New-Item][04]
- [Set-Item][14]

## Using the pipeline

Expand All @@ -309,10 +305,8 @@ Beginning in Windows PowerShell 3.0, you can get customized help topics for
provider cmdlets that explain how those cmdlets behave in a file system drive.

To get the help topics that are customized for the file system drive, run a
[Get-Help](xref:Microsoft.PowerShell.Core.Get-Help) command in a file system
drive or use the `-Path` parameter of
[Get-Help](xref:Microsoft.PowerShell.Core.Get-Help) to specify a file system
drive.
[Get-Help][15] command in a file system drive or use the `-Path` parameter of
[Get-Help][15] to specify a file system drive.

```powershell
Get-Help Get-ChildItem
Expand All @@ -324,5 +318,24 @@ Get-Help Get-ChildItem -Path alias:

## See also

- [about_Aliases](about_Aliases.md)
- [about_Providers](about_Providers.md)
- [about_Aliases][16]
- [about_Providers][17]

<!-- External links -->
[01]: xref:Microsoft.PowerShell.Management.Get-Location
[02]: xref:Microsoft.PowerShell.Management.Set-Location
[03]: xref:Microsoft.PowerShell.Management.Get-Item
[04]: xref:Microsoft.PowerShell.Management.New-Item
[05]: xref:Microsoft.PowerShell.Management.Remove-Item
[06]: xref:Microsoft.PowerShell.Management.Clear-Item
[07]: xref:Microsoft.PowerShell.Utility.Export-Alias
[08]: xref:Microsoft.PowerShell.Utility.Get-Alias
[09]: xref:Microsoft.PowerShell.Utility.Import-Alias
[10]: xref:Microsoft.PowerShell.Utility.New-Alias
[11]: xref:Microsoft.PowerShell.Utility.Set-Alias
[12]: /dotnet/api/system.management.automation.aliasinfo
[13]: xref:Microsoft.PowerShell.Management.Get-ChildItem
[14]: xref:Microsoft.PowerShell.Management.Set-Item
[15]: xref:Microsoft.PowerShell.Core.Get-Help
[16]: about_Aliases.md
[17]: about_Providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ in the current session, type:
Get-Alias
```

To get particular aliases, use the Name parameter of the `Get-Alias` cmdlet. For
example, to get aliases that begin with "p", type:
To get particular aliases, use the Name parameter of the `Get-Alias` cmdlet.
For example, to get aliases that begin with "p", type:

```powershell
Get-Alias -Name p*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ title: about_Arithmetic_Operators
# about_Arithmetic_Operators

## Short description

Describes the operators that perform arithmetic in PowerShell.

## Long description
Expand Down Expand Up @@ -202,7 +203,7 @@ result without losing precision. For example:
(2 + 3.1).GetType().FullName
```

```output
```Output
5.1
System.Int32
System.Double
Expand All @@ -216,7 +217,7 @@ is widened to accommodate the result, as in the following example:
(512MB * 512MB).GetType().FullName
```

```output
```Output
System.Int32
System.Double
```
Expand All @@ -226,10 +227,10 @@ following example, the negative value can't be cast to an unsigned integer, and
the unsigned integer is too large to be cast to `Int32`:

```powershell
([int32]::minvalue + [uint32]::maxvalue).gettype().fullname
([int32]::minvalue + [uint32]::maxvalue).GetType().FullName
```

```output
```Output
System.Int64
```

Expand Down Expand Up @@ -268,8 +269,8 @@ PS> [ulong](9223372036854775807 + 2)
9223372036854775808
```

Defining the larger value as `[ulong]` first avoids the problem and produces the
correct result.
Defining the larger value as `[ulong]` first avoids the problem and produces
the correct result.

```powershell
PS> 9223372036854775807ul + 2
Expand Down Expand Up @@ -326,7 +327,7 @@ $b = "A","B","C"
$a + $b
```

```output
```Output
1
2
3
Expand Down Expand Up @@ -389,7 +390,7 @@ $hash2 = @{c1="Server01"; c2="Server02"}
$hash1 + $hash2
```

```output
```Output
Name Value
---- -----
c2 Server02
Expand All @@ -408,7 +409,7 @@ $hash2 = @{c1="Server01"; c="Server02"}
$hash1 + $hash2
```

```output
```Output
OperationStopped:
Line |
3 | $hash1 + $hash2
Expand All @@ -426,7 +427,7 @@ $array2 = $array1 + $hash1
$array2
```

```output
```Output
0
Hello World

Expand All @@ -447,7 +448,7 @@ However, you can't add any other type to a hash table.
$hash1 + 2
```

```output
```Output
InvalidOperation: A hash table can only be added to another hash table.
```

Expand All @@ -462,7 +463,7 @@ $array = @()
$array
```

```output
```Output
0
1
2
Expand Down Expand Up @@ -507,7 +508,7 @@ results are then added using the `+` operator.
Get-Process | Where-Object { ($_.ws * 2) -gt 50mb }
```

```output
```Output
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
1896 39 50968 30620 264 1,572.55 1104 explorer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ values of a particular type, cast the variable as an array type, such as
variable name with an array type enclosed in brackets. For example:

```powershell
[int32[]]$ia = 1500, 2230, 3350, 4000
[Int32[]]$ia = 1500, 2230, 3350, 4000
```

As a result, the `$ia` array can contain only integers.
Expand Down Expand Up @@ -639,8 +639,8 @@ The value of `mode` must be a [WhereOperatorSelectionMode][02] enum value:
- `Default` (`0`) - Return all items
- `First` (`1`) - Return the first item
- `Last` (`2`) - Return the last item
- `SkipUntil` (`3`) - Skip items until condition is true, return all the remaining
items (including the first item for which the condition is true)
- `SkipUntil` (`3`) - Skip items until condition is true, return all the
remaining items (including the first item for which the condition is true)
- `Until` (`4`) - Return all items until condition is true
- `Split` (`5`) - Return an array of two elements
- The first element contains matching items
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ title: about_Assignment_Operators
# about_Assignment_Operators

## Short description

Describes how to use operators to assign values to variables.

## Long description
Expand Down Expand Up @@ -50,10 +51,10 @@ $MyShell = "PowerShell"
```

When you assign a value to a variable in PowerShell, the variable is created if
it didn't already exist. For example, the first of the following two
assignment statements creates the `$a` variable and assigns a value of 6 to
`$a`. The second assignment statement assigns a value of 12 to `$a`. The first
statement creates a new variable. The second statement changes only its value:
it didn't already exist. For example, the first of the following two assignment
statements creates the `$a` variable and assigns a value of 6 to `$a`. The
second assignment statement assigns a value of 12 to `$a`. The first statement
creates a new variable. The second statement changes only its value:

```powershell
$a = 6
Expand Down Expand Up @@ -142,20 +143,35 @@ Compound assignment operators perform numeric operations on the values before
the assignment.

> [!IMPORTANT]
> Compound assignment operators do not use dynamic scoping. The variable is
> always in the current scope. In the following example, the variable `$x` is
> defined in the global scope. The braces create a new scope. The variable `$x`
> inside the braces is a new instance and not a reference to the global
> variable.
>
> ```powershell
> $x = 1 # Global scope
> & { $x += 1; $x }
> ```
>
> ```Output
> 1
> ```
> Compound assignment operators don't use dynamic scoping. The variable is
> always in the current scope.

In the following example, the variable `$x` is defined in the global scope. The
braces create a new scope. The variable `$x` inside the braces is a new
instance and not a copy of the global variable.

```powershell
$x = 1 # Global scope
& { $x += 1; $x }
```

```Output
1
```

When you use the regular assignment operator, you get a copy of the variable
from the parent scope. But notice that `$x` in the parent scope is not changed.

```powershell
$x = 1 # Global scope
& { $x = $x + 1; $x }
"Global `$x = $x"
```

```Output
2
Global $x = 1
```

### The assignment by addition operator

Expand Down Expand Up @@ -183,7 +199,7 @@ $a += 2
$a
```

```
```Output
6
```

Expand Down Expand Up @@ -240,7 +256,7 @@ assignments fail.

For example, the following command assigns a hash table to the `$a` variable.
Then, it uses the `+=` operator to append another hash table to the existing
hash table, effectively adding a new key/value pair to the existing hash table.
hash table, effectively adding a new key-value pair to the existing hash table.
This command succeeds, as shown in the output:

```powershell
Expand Down Expand Up @@ -279,8 +295,8 @@ At line:2 char:1

The assignment by subtraction operator `-=` decrements the value of a variable
by the value that's specified on the right side of the operator. This operator
can't be used with string variables, and it can't be used to remove an
element from a collection.
can't be used with string variables, and it can't be used to remove an element
from a collection.

The `-=` operator combines two operations. First, it subtracts, and then it
assigns. Therefore, the following statements are equivalent:
Expand Down
Loading