I have the following script:
$PathToFiles = 'C:\Data_Files\Debug'
$Files = Get-ChildItem -Path $PathToFiles| Where-Object {$_.Fullname -match "[0-9]{15}\.xml"}
$Files|ForEach-Object{
$ID = [io.path]::GetFileNameWithoutExtension($_.Name)
$Data = [PSCustomObject] @{
ID = $ID
PathToFiles = $PathToFiles
}
Write-Output -InputObject $Data
}
I am attempting to use the pipeline as input to a different PS script.
The command line looks like .\PS1.ps1 | .\PS2.ps1
The PS2.ps1 script correctly processes the input object if I simply feed a single object through the pipeline to it. If I run this script just as .\PS1.ps1 I get a long list of the object that I am outputting, but when I run it attempting to send through the pipeline, only the last object processed is passed through to the second script. How do I get all the objects processing?