0

I'm working with a table that I extracted from HTML, but the name field is actually 2 rows (one for name and one for ID)

This is what I have

(Get-Content C:\test\test.csv) | 
Foreach-Object {$_ -replace "Assigned To", "Assigned To,ID"`
-replace ",,,ID: ", ""`
-replace "[0-9],,,", ""`
-replace ",`n", ","}
Set-Content C:\test\Test.txt

I'm running into two problems: When I run this in the powershell window, it seems to execute fine, but when I right clicked the saved script and execute, it says:

cmdlet Set-Content at command pipeline position 1
Supply values for the following parameters:
Value[0]: 

I assume this has to do with the -replace "[0-9],,,", ""

Does anyone know how what I'm doing wrong there?

1
  • Your second issue isn't relevant, please create a new question for that, with a sample of your input file Commented Apr 15, 2014 at 18:51

1 Answer 1

1

It is pretty obvious that powershell wants you to "Supply values for the following parameters: Value[0]: "

http://technet.microsoft.com/en-us/library/hh849828.aspx

You only gave it the path parameter. I'm assuming you meant to pipe the "Value" parameter into the set-content cmdlet:

(Get-Content C:\test\test.csv) | Foreach-Object {
    $_ -replace "Assigned To", "Assigned To,ID"`
    -replace ",,,ID: ", ""`
    -replace "[0-9],,,", ""`
    -replace ",`n", ","
} | Set-Content C:\test\Test.txt
Sign up to request clarification or add additional context in comments.

1 Comment

That is what I was missing. Thanks!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.