Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2/28/2024 PM Publish #10914

Merged
merged 2 commits into from
Feb 28, 2024
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
22 changes: 21 additions & 1 deletion reference/5.1/Microsoft.PowerShell.Core/About/about_Switch.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: Explains how to use a switch to handle multiple `if` statements.
Locale: en-US
ms.date: 01/27/2022
ms.date: 02/28/2024
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_switch?view=powershell-5.1&WT.mc_id=ps-gethelp
schema: 2.0.0
title: about Switch
Expand Down Expand Up @@ -223,6 +223,26 @@ switch (4, 2)
It is four.
```

In this example, the `switch` statement is testing for the type of the value in
the hashtable. You must use and expression that returns a boolean value to
select the scriptblock to execute.

```powershell
$var = @{A = 10; B = 'abc'}

foreach ($key in $var.Keys) {
switch ($var[$key].GetType()) {
{ $_ -eq [int32] } { "$key + 10 = $($var[$key] + 10)" }
{ $_ -eq [string] } { "$key = $($var[$key])" }
}
}
```

```Output
A + 10 = 20
B = abc
```

In this example, an object that's not a string or numerical data is passed to
the `switch`. The `switch` performs a string coercion on the object and
evaluates the outcome.
Expand Down
16 changes: 8 additions & 8 deletions reference/5.1/Microsoft.PowerShell.Management/New-Item.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: ByValue (False), ByName (False)
Accept pipeline input: False
Accept wildcard characters: False
```

Expand All @@ -285,7 +285,7 @@ Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: ByValue (False), ByName (False)
Accept pipeline input: False
Accept wildcard characters: False
```

Expand All @@ -307,7 +307,7 @@ Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: ByValue (False), ByName (False)
Accept pipeline input: False
Accept wildcard characters: False
```

Expand All @@ -328,7 +328,7 @@ Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: ByValue (False), ByName (False)
Accept pipeline input: False
Accept wildcard characters: False
```

Expand Down Expand Up @@ -452,7 +452,7 @@ Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: ByValue (False), ByName (False)
Accept pipeline input: False
Accept wildcard characters: False
```

Expand All @@ -473,7 +473,7 @@ Aliases: OS
Required: False
Position: Named
Default value: None
Accept pipeline input: ByValue (False), ByName (False)
Accept pipeline input: False
Accept wildcard characters: False
```

Expand Down Expand Up @@ -518,7 +518,7 @@ Aliases:
Required: False False
Position: Named
Default value: None
Accept pipeline input: ByValue (System.Object[]), ByName (System.Object[])
Accept pipeline input: False
Accept wildcard characters: False
```

Expand All @@ -539,7 +539,7 @@ Aliases: SO
Required: False
Position: Named
Default value: None
Accept pipeline input: ByValue (False), ByName (False)
Accept pipeline input: False
Accept wildcard characters: False
```

Expand Down
4 changes: 2 additions & 2 deletions reference/5.1/Microsoft.PowerShell.Management/Set-Item.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: ByValue (False), ByName (False)
Accept pipeline input: False
Accept wildcard characters: False
```

Expand Down Expand Up @@ -315,7 +315,7 @@ Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: ByValue (False), ByName (True)
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

Expand Down
4 changes: 2 additions & 2 deletions reference/5.1/Microsoft.PowerShell.Management/Test-Path.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: ByValue (False), ByName (False)
Accept pipeline input: False
Accept wildcard characters: False
```

Expand Down Expand Up @@ -387,7 +387,7 @@ Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: ByValue (False), ByName (False)
Accept pipeline input: False
Accept wildcard characters: False
```

Expand Down
22 changes: 21 additions & 1 deletion reference/7.2/Microsoft.PowerShell.Core/About/about_Switch.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: Explains how to use a switch to handle multiple `if` statements.
Locale: en-US
ms.date: 01/27/2022
ms.date: 02/28/2024
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_switch?view=powershell-7.2&WT.mc_id=ps-gethelp
schema: 2.0.0
title: about Switch
Expand Down Expand Up @@ -223,6 +223,26 @@ switch (4, 2)
It is four.
```

In this example, the `switch` statement is testing for the type of the value in
the hashtable. You must use and expression that returns a boolean value to
select the scriptblock to execute.

```powershell
$var = @{A = 10; B = 'abc'}

foreach ($key in $var.Keys) {
switch ($var[$key].GetType()) {
{ $_ -eq [int32] } { "$key + 10 = $($var[$key] + 10)" }
{ $_ -eq [string] } { "$key = $($var[$key])" }
}
}
```

```Output
A + 10 = 20
B = abc
```

In this example, an object that's not a string or numerical data is passed to
the `switch`. The `switch` performs a string coercion on the object and
evaluates the outcome.
Expand Down
18 changes: 9 additions & 9 deletions reference/7.2/Microsoft.PowerShell.Management/New-Item.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: ByValue (False), ByName (False)
Accept pipeline input: False
Accept wildcard characters: False
```

Expand All @@ -285,7 +285,7 @@ Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: ByValue (False), ByName (False)
Accept pipeline input: False
Accept wildcard characters: False
```

Expand All @@ -307,7 +307,7 @@ Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: ByValue (False), ByName (False)
Accept pipeline input: False
Accept wildcard characters: False
```

Expand All @@ -328,7 +328,7 @@ Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: ByValue (False), ByName (False)
Accept pipeline input: False
Accept wildcard characters: False
```

Expand Down Expand Up @@ -454,7 +454,7 @@ Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: ByValue (False), ByName (False)
Accept pipeline input: False
Accept wildcard characters: False
```

Expand All @@ -475,7 +475,7 @@ Aliases: OS
Required: False
Position: Named
Default value: None
Accept pipeline input: ByValue (False), ByName (False)
Accept pipeline input: False
Accept wildcard characters: False
```

Expand Down Expand Up @@ -520,7 +520,7 @@ Aliases:
Required: False False
Position: Named
Default value: None
Accept pipeline input: ByValue (System.Object[]), ByName (System.Object[])
Accept pipeline input: False
Accept wildcard characters: False
```

Expand All @@ -541,7 +541,7 @@ Aliases: SO
Required: False
Position: Named
Default value: None
Accept pipeline input: ByValue (False), ByName (False)
Accept pipeline input: False
Accept wildcard characters: False
```

Expand All @@ -563,7 +563,7 @@ Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: ByValue (False), ByName (False)
Accept pipeline input: False
Accept wildcard characters: False
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: ByValue (False), ByName (False)
Accept pipeline input: False
Accept wildcard characters: False
```

Expand Down Expand Up @@ -246,7 +246,7 @@ Accepted values: ASCII, BigEndianUnicode, BigEndianUTF32, OEM, Unicode, UTF7, UT
Required: False
Position: Named
Default value: utf8NoBOM
Accept pipeline input: ByValue (False), ByName (False)
Accept pipeline input: False
Accept wildcard characters: False
```

Expand Down Expand Up @@ -369,7 +369,7 @@ Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: ByValue (False), ByName (False)
Accept pipeline input: False
Accept wildcard characters: False
```

Expand Down Expand Up @@ -434,7 +434,7 @@ Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: ByValue (False), ByName (False)
Accept pipeline input: False
Accept wildcard characters: False
```

Expand Down
4 changes: 2 additions & 2 deletions reference/7.2/Microsoft.PowerShell.Management/Set-Item.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: ByValue (False), ByName (False)
Accept pipeline input: False
Accept wildcard characters: False
```

Expand Down Expand Up @@ -315,7 +315,7 @@ Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: ByValue (False), ByName (True)
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: ByValue (False), ByName (True)
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

Expand Down
4 changes: 2 additions & 2 deletions reference/7.2/Microsoft.PowerShell.Management/Test-Path.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: ByValue (False), ByName (False)
Accept pipeline input: False
Accept wildcard characters: False
```

Expand Down Expand Up @@ -380,7 +380,7 @@ Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: ByValue (False), ByName (False)
Accept pipeline input: False
Accept wildcard characters: False
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ Aliases: Msg, Message
Required: True
Position: 0
Default value: None
Accept pipeline input: ByValue (True), ByName (False)
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```

Expand All @@ -212,7 +212,7 @@ Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: ByValue (False), ByName (False)
Accept pipeline input: False
Accept wildcard characters: False
```

Expand Down
22 changes: 21 additions & 1 deletion reference/7.3/Microsoft.PowerShell.Core/About/about_Switch.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: Explains how to use a switch to handle multiple `if` statements.
Locale: en-US
ms.date: 01/27/2022
ms.date: 02/28/2024
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_switch?view=powershell-7.3&WT.mc_id=ps-gethelp
schema: 2.0.0
title: about Switch
Expand Down Expand Up @@ -223,6 +223,26 @@ switch (4, 2)
It is four.
```

In this example, the `switch` statement is testing for the type of the value in
the hashtable. You must use and expression that returns a boolean value to
select the scriptblock to execute.

```powershell
$var = @{A = 10; B = 'abc'}

foreach ($key in $var.Keys) {
switch ($var[$key].GetType()) {
{ $_ -eq [int32] } { "$key + 10 = $($var[$key] + 10)" }
{ $_ -eq [string] } { "$key = $($var[$key])" }
}
}
```

```Output
A + 10 = 20
B = abc
```

In this example, an object that's not a string or numerical data is passed to
the `switch`. The `switch` performs a string coercion on the object and
evaluates the outcome.
Expand Down
Loading
Loading