- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is splatting in PowerShell?
PowerShell splatting is a method to pass the collection of the parameters as a single command unit which makes the command shorter and easier for the user to read commands. Splatting uses the symbol (@) instead of ($) which tells the user that splatting is used and PowerShell is passing a set of values instead of a single value.
Splatting in PowerShell was included from the v3.0 onwards and you can pass all parameters in the command.
For example,
$params = @{ Path = 'C:\Temp\25Aug2020.txt' Destination = 'C:\test1' Verbose = $true Force = $true } Copy-Item @params
The splatting parameters can be used with Hashtable and with an Array.
Hashtable splatting is a combination of the Name and value pair. You can use this format for all parameter types, including Positional and Switch parameters. Positional parameters must be assigned by name.
Array Splatting uses values of the positional parameter, which do not require parameter names. The values must be in the positional number order in an array.
Positional parameters can be identified with the Help command. For example, to identify the Copy-Item positional parameters, use the below command.
help Copy-Item -Parameter *
- Related Articles
- How to use Hashtable splatting in PowerShell?
- How to use Array Splatting in PowerShell?
- What is Array in PowerShell?
- What is Hash Table in PowerShell?
- What is an alias in PowerShell?
- What is the breakpoint in PowerShell?
- What is PowerShell Break statement?
- What is the PowerShell Workflow?
- What is Get-ChildItem cmdlet in PowerShell?
- What is Copy-item in PowerShell used for?
- What is Get-Content in PowerShell used for?
- What is the use of $ErrorView in PowerShell?
- What is use of $error variable in PowerShell?
- What is PowerShell Desired State Configuration?
- What is terminating and non-terminating errors in PowerShell?
