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

1/29/2024 PM Publish #10838

Merged
merged 1 commit into from
Jan 29, 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
60 changes: 44 additions & 16 deletions reference/5.1/Microsoft.PowerShell.Core/About/about_Splatting.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: Describes how to use splatting to pass parameters to commands in PowerShell.
Locale: en-US
ms.date: 12/12/2022
ms.date: 01/29/2024
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_splatting?view=powershell-5.1&WT.mc_id=ps-gethelp
schema: 2.0.0
title: about Splatting
Expand Down Expand Up @@ -231,6 +231,26 @@ b = 2
c = 3
```

### Example 3: Using multiple splatted objects in a single command

You can use multiple splatted objects in a single command. In this example,
different parameters are defined in separate hashtables. The hashtables are
splatted in a single `Write-Host` command.

```powershell
$a = @{
Message = 'Hello', 'World!'
}
$b = @{
Separator = '|'
}
$c = @{
BackgroundColor = 'Cyan'
ForegroundColor = 'Black'
}
Write-Host @a @b @c
```

## Splatting command parameters

You can use splatting to represent the parameters of a command. This technique
Expand Down Expand Up @@ -290,13 +310,15 @@ Get-MyCommand -P -C -Name PowerShell
```

```Output
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
408 28 75568 83176 620 1.33 1692 powershell
Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName
------- ------ ----- ----- ------ -- -- -----------
830 50 115840 95524 16.75 6880 1 powershell
Path : C:\Windows\System32\WindowsPowerShell\v1.0\powershell.e
Path : C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Extension : .exe
Definition : C:\Windows\System32\WindowsPowerShell\v1.0\powershell.e
Definition : C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Source : C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Version : 10.0.22621.3085
Visibility : Public
OutputType : {System.String}
Name : powershell.exe
Expand All @@ -307,14 +329,13 @@ RemotingCapability : PowerShell
Parameters :
ParameterSets :
HelpUri :
FileVersionInfo : File: C:\Windows\System32\WindowsPowerShell
\v1.0\powershell.exe
FileVersionInfo : File: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
InternalName: POWERSHELL
OriginalFilename: PowerShell.EXE.MUI
FileVersion: 10.0.14393.0 (rs1_release.160715-1616
FileVersion: 10.0.22621.1 (WinBuild.160101.0800)
FileDescription: Windows PowerShell
Product: Microsoft Windows Operating System
ProductVersion: 10.0.14393.0
Product: Microsoft® Windows® Operating System
ProductVersion: 10.0.22621.1
Debug: False
Patched: False
PreRelease: False
Expand All @@ -332,11 +353,18 @@ parameter definition.

PowerShell Desired State Configuration (DSC) was not designed to use splatting.
You cannot use splatting to pass values into a DSC resource. For more
information, see Gael Colas' article [Pseudo-Splatting DSC Resources](https://gaelcolas.com/2017/11/05/pseudo-splatting-dsc-resources/).
information, see Gael Colas' article [Pseudo-Splatting DSC Resources][05].

## See also

- [about_Arrays](about_Arrays.md)
- [about_Automatic_Variables](about_Automatic_Variables.md)
- [about_Hash_Tables](about_Hash_Tables.md)
- [about_Parameters](about_Parameters.md)
- [about_Arrays][01]
- [about_Automatic_Variables][02]
- [about_Hash_Tables][03]
- [about_Parameters][04]

<!-- link references -->
[01]: about_Arrays.md
[02]: about_Automatic_Variables.md
[03]: about_Hash_Tables.md
[04]: about_Parameters.md
[05]: https://gaelcolas.com/2017/11/05/pseudo-splatting-dsc-resources/
4 changes: 2 additions & 2 deletions reference/5.1/Microsoft.PowerShell.Management/New-Item.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
Locale: en-US
Module Name: Microsoft.PowerShell.Management
ms.date: 06/30/2023
ms.date: 01/29/2024
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.management/new-item?view=powershell-5.1&WT.mc_id=ps-gethelp
schema: 2.0.0
title: New-Item
Expand Down Expand Up @@ -221,7 +221,7 @@ Mode LastWriteTime Length Name
### Example 9: Use the -Force parameter to overwrite existing files

This example creates a file with a value and then recreates the file using `-Force`. This overwrites
The existing file and it will lose it's content as you can see by the length property
the existing file, as you can see by the length property.

```powershell
PS> New-Item ./TestFile.txt -ItemType File -Value 'This is just a test file'
Expand Down
60 changes: 44 additions & 16 deletions reference/7.2/Microsoft.PowerShell.Core/About/about_Splatting.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: Describes how to use splatting to pass parameters to commands in PowerShell.
Locale: en-US
ms.date: 12/12/2022
ms.date: 01/29/2024
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_splatting?view=powershell-7.2&WT.mc_id=ps-gethelp
schema: 2.0.0
title: about Splatting
Expand Down Expand Up @@ -274,6 +274,26 @@ foreach ($vm in $allVms)
}
```

### Example 4: Using multiple splatted objects in a single command

You can use multiple splatted objects in a single command. In this example,
different parameters are defined in separate hashtables. The hashtables are
splatted in a single `Write-Host` command.

```powershell
$a = @{
Message = 'Hello', 'World!'
}
$b = @{
Separator = '|'
}
$c = @{
BackgroundColor = 'Cyan'
ForegroundColor = 'Black'
}
Write-Host @a @b @c
```

## Splatting command parameters

You can use splatting to represent the parameters of a command. This technique
Expand Down Expand Up @@ -333,13 +353,15 @@ Get-MyCommand -P -C -Name PowerShell
```

```Output
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
408 28 75568 83176 620 1.33 1692 powershell
NPM(K) PM(M) WS(M) CPU(s) Id SI ProcessName
------ ----- ----- ------ -- -- -----------
50 112.76 78.52 16.64 6880 1 powershell
Path : C:\Windows\System32\WindowsPowerShell\v1.0\powershell.e
Path : C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Extension : .exe
Definition : C:\Windows\System32\WindowsPowerShell\v1.0\powershell.e
Definition : C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Source : C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Version : 10.0.22621.3085
Visibility : Public
OutputType : {System.String}
Name : powershell.exe
Expand All @@ -350,14 +372,13 @@ RemotingCapability : PowerShell
Parameters :
ParameterSets :
HelpUri :
FileVersionInfo : File: C:\Windows\System32\WindowsPowerShell
\v1.0\powershell.exe
FileVersionInfo : File: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
InternalName: POWERSHELL
OriginalFilename: PowerShell.EXE.MUI
FileVersion: 10.0.14393.0 (rs1_release.160715-1616
FileVersion: 10.0.22621.1 (WinBuild.160101.0800)
FileDescription: Windows PowerShell
Product: Microsoft Windows Operating System
ProductVersion: 10.0.14393.0
Product: Microsoft&reg; Windows&reg; Operating System
ProductVersion: 10.0.22621.1
Debug: False
Patched: False
PreRelease: False
Expand All @@ -375,11 +396,18 @@ parameter definition.

PowerShell Desired State Configuration (DSC) was not designed to use splatting.
You cannot use splatting to pass values into a DSC resource. For more
information, see Gael Colas' article [Pseudo-Splatting DSC Resources](https://gaelcolas.com/2017/11/05/pseudo-splatting-dsc-resources/).
information, see Gael Colas' article [Pseudo-Splatting DSC Resources][05].

## See also

- [about_Arrays](about_Arrays.md)
- [about_Automatic_Variables](about_Automatic_Variables.md)
- [about_Hash_Tables](about_Hash_Tables.md)
- [about_Parameters](about_Parameters.md)
- [about_Arrays][01]
- [about_Automatic_Variables][02]
- [about_Hash_Tables][03]
- [about_Parameters][04]

<!-- link references -->
[01]: about_Arrays.md
[02]: about_Automatic_Variables.md
[03]: about_Hash_Tables.md
[04]: about_Parameters.md
[05]: https://gaelcolas.com/2017/11/05/pseudo-splatting-dsc-resources/
4 changes: 2 additions & 2 deletions reference/7.2/Microsoft.PowerShell.Management/New-Item.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
Locale: en-US
Module Name: Microsoft.PowerShell.Management
ms.date: 06/30/2023
ms.date: 01/29/2024
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.management/new-item?view=powershell-7.2&WT.mc_id=ps-gethelp
schema: 2.0.0
title: New-Item
Expand Down Expand Up @@ -221,7 +221,7 @@ Mode LastWriteTime Length Name
### Example 9: Use the -Force parameter to overwrite existing files

This example creates a file with a value and then recreates the file using `-Force`. This overwrites
The existing file and it will lose it's content as you can see by the length property
the existing file, as you can see by the length property.

```powershell
PS> New-Item ./TestFile.txt -ItemType File -Value 'This is just a test file'
Expand Down
60 changes: 44 additions & 16 deletions reference/7.3/Microsoft.PowerShell.Core/About/about_Splatting.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: Describes how to use splatting to pass parameters to commands in PowerShell.
Locale: en-US
ms.date: 12/12/2022
ms.date: 01/29/2024
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_splatting?view=powershell-7.3&WT.mc_id=ps-gethelp
schema: 2.0.0
title: about Splatting
Expand Down Expand Up @@ -274,6 +274,26 @@ foreach ($vm in $allVms)
}
```

### Example 4: Using multiple splatted objects in a single command

You can use multiple splatted objects in a single command. In this example,
different parameters are defined in separate hashtables. The hashtables are
splatted in a single `Write-Host` command.

```powershell
$a = @{
Message = 'Hello', 'World!'
}
$b = @{
Separator = '|'
}
$c = @{
BackgroundColor = 'Cyan'
ForegroundColor = 'Black'
}
Write-Host @a @b @c
```

## Splatting command parameters

You can use splatting to represent the parameters of a command. This technique
Expand Down Expand Up @@ -333,13 +353,15 @@ Get-MyCommand -P -C -Name PowerShell
```

```Output
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
408 28 75568 83176 620 1.33 1692 powershell
NPM(K) PM(M) WS(M) CPU(s) Id SI ProcessName
------ ----- ----- ------ -- -- -----------
50 112.76 78.52 16.64 6880 1 powershell
Path : C:\Windows\System32\WindowsPowerShell\v1.0\powershell.e
Path : C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Extension : .exe
Definition : C:\Windows\System32\WindowsPowerShell\v1.0\powershell.e
Definition : C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Source : C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Version : 10.0.22621.3085
Visibility : Public
OutputType : {System.String}
Name : powershell.exe
Expand All @@ -350,14 +372,13 @@ RemotingCapability : PowerShell
Parameters :
ParameterSets :
HelpUri :
FileVersionInfo : File: C:\Windows\System32\WindowsPowerShell
\v1.0\powershell.exe
FileVersionInfo : File: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
InternalName: POWERSHELL
OriginalFilename: PowerShell.EXE.MUI
FileVersion: 10.0.14393.0 (rs1_release.160715-1616
FileVersion: 10.0.22621.1 (WinBuild.160101.0800)
FileDescription: Windows PowerShell
Product: Microsoft Windows Operating System
ProductVersion: 10.0.14393.0
Product: Microsoft&reg; Windows&reg; Operating System
ProductVersion: 10.0.22621.1
Debug: False
Patched: False
PreRelease: False
Expand All @@ -375,11 +396,18 @@ parameter definition.

PowerShell Desired State Configuration (DSC) was not designed to use splatting.
You cannot use splatting to pass values into a DSC resource. For more
information, see Gael Colas' article [Pseudo-Splatting DSC Resources](https://gaelcolas.com/2017/11/05/pseudo-splatting-dsc-resources/).
information, see Gael Colas' article [Pseudo-Splatting DSC Resources][05].

## See also

- [about_Arrays](about_Arrays.md)
- [about_Automatic_Variables](about_Automatic_Variables.md)
- [about_Hash_Tables](about_Hash_Tables.md)
- [about_Parameters](about_Parameters.md)
- [about_Arrays][01]
- [about_Automatic_Variables][02]
- [about_Hash_Tables][03]
- [about_Parameters][04]

<!-- link references -->
[01]: about_Arrays.md
[02]: about_Automatic_Variables.md
[03]: about_Hash_Tables.md
[04]: about_Parameters.md
[05]: https://gaelcolas.com/2017/11/05/pseudo-splatting-dsc-resources/
4 changes: 2 additions & 2 deletions reference/7.3/Microsoft.PowerShell.Management/New-Item.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
Locale: en-US
Module Name: Microsoft.PowerShell.Management
ms.date: 06/30/2023
ms.date: 01/29/2024
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.management/new-item?view=powershell-7.3&WT.mc_id=ps-gethelp
schema: 2.0.0
title: New-Item
Expand Down Expand Up @@ -221,7 +221,7 @@ Mode LastWriteTime Length Name
### Example 9: Use the -Force parameter to overwrite existing files

This example creates a file with a value and then recreates the file using `-Force`. This overwrites
The existing file and it will lose it's content as you can see by the length property
the existing file, as you can see by the length property.

```powershell
PS> New-Item ./TestFile.txt -ItemType File -Value 'This is just a test file'
Expand Down
Loading