Shell – Piping all output from Get-ChildItem

powershell

I'm trying to make a basic powershell command work, but I'm having some difficulty with the piping system.

I'm using Fossil for my version control system, and have made the majority of my programs structure. Running the command:

get-childitem -r | fossil add {$_.fullname}

Gives me the error

not found: E:/workspace/project/-encodedCommand
not found: E:/workspace/project/JABfAC4AZgB1AGwAbABuAGEAbQBlAA==
not found: E:/workspace/project/-inputFormat
not found: E:/workspace/project/xml
not found: E:/workspace/project/-outputFormat
not found: E:/workspace/project/text

Best Answer

Assuming fossil is a command used with your version control system, based on skimming through the users guide.

You will need to pass each $_.FullName into the fossil command one at a time in order for it to successfully process the file for you. You would do this using the foreach command. So it would look like:


Get-ChildItem -Recurse | foreach {fossil add $_.FullName}

You need to think in terms that each time you add the | it is passing all of the object properties to the next process or command. In your instance $_.FullName is the specific object you want to work with in the next segment. Calling the command for your version control system it has to be passed in one at a time, you do this using the foreach command.

Related Question