2

My understanding is that PowerShell cmdlet only accept input through parameters and there are 2 ways to pass data down the pipeline: ByValue and ByProperty.

In the example below, I dont understand why it works.

Get-ChildItem .\ -Filter *.txt* | Copy-Item -Destination .\Wonderland\

Object type of Get-ChildItem is System.IO.FileInfo, there is no parameter of Copy-Item that acceps that type so ByValue does not work here.

I'm assuming the parameter -Path of Copy-Item will accept input from Get-ChildItem but there is no -Path property in Get-ChildItem. By this logic, it will not work.

Am i missing anything?

The One
  • 2,261
  • 6
  • 22
  • 38
  • 2
    It binds by PropertyName using the ETS `PSPath` property from the File and Directory Info objects. The objects are bound to the `-LiteralPath` parameter which has the `PSPath` as alias. – Santiago Squarzon Dec 01 '22 at 02:57

0 Answers0