Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
share|improve this question
up vote 2 down vote accepted

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.

share|improve this answer
Oh okay, I thought a for each was implied with the pipe operator. That works perfectly. – Jacobm001 Dec 28 '13 at 20:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .