none
Empty Pipe element is not allowed RRS feed

  • Question

  • I have googled multiple things today but cant seem to figure out how to export my information to a csv or any time of document so I can email it to myself. Below is my working script. I have tried to add:

     | Export-csv "C:\users\tjohnson\TE.csv"

    When I type that I get the error saying Empty pipe element not allowed. I feel like their should be an easy solution I am missing.

    $cred = Import-Clixml -Path C:\users\tjohnson\PW.xml
    $url = "http://google.com"
    $response=Invoke-WebRequest $url -Credential $cred
       
       
       if ($response.statuscode -eq 200) {
          "Success`t`t" + $startTime.DateTime + "`t`t" + ($endTime - $startTime).TotalSeconds + " seconds"
       } else {
          "Fail`t`t" + $startTime.DateTime + "`t`t" + ($endTime - $startTime).TotalSeconds + " seconds"
       }
    

    Tuesday, February 10, 2015 9:47 PM

Answers

  • Hi Bohlingj,

    that error means you are not only not passing any information to Export-Csv, but don't even try to, which Powershell takes exception to. If you want to output the result of if / else segments, you can pipe them into Out-File -Append like this:

    "Success`t`t" + $startTime.DateTime + "`t`t" + ($endTime - $startTime).TotalSeconds + " seconds" | Out-File "C:\temp\connectlog.log" -Append

    This will write that line as a new line to the specified text file.

    Given the way you output information, exporting as Csv doesn't do you all that much good.

    Cheers,
    Fred


    There's no place like 127.0.0.1

    • Marked as answer by bohlingj Wednesday, February 11, 2015 1:48 PM
    Wednesday, February 11, 2015 1:13 PM

All replies

  • You need to post the complete error message.

    It cannot be coming from the script you posted.


    ¯\_(ツ)_/¯

    Tuesday, February 10, 2015 11:23 PM
  • At line:11 char:4
    +    | export-csv "C:\Users\xxxxx\Desktop\TE.csv"
    +    ~
    An empty pipe element is not allowed.
        + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
        + FullyQualifiedErrorId : EmptyPipeElement
    Wednesday, February 11, 2015 12:52 PM
  • Hi Bohlingj,

    that error means you are not only not passing any information to Export-Csv, but don't even try to, which Powershell takes exception to. If you want to output the result of if / else segments, you can pipe them into Out-File -Append like this:

    "Success`t`t" + $startTime.DateTime + "`t`t" + ($endTime - $startTime).TotalSeconds + " seconds" | Out-File "C:\temp\connectlog.log" -Append

    This will write that line as a new line to the specified text file.

    Given the way you output information, exporting as Csv doesn't do you all that much good.

    Cheers,
    Fred


    There's no place like 127.0.0.1

    • Marked as answer by bohlingj Wednesday, February 11, 2015 1:48 PM
    Wednesday, February 11, 2015 1:13 PM
  • Is there nothing before the pipe?  If this line is at the end of of the above code then the error correct.  You should assign the text you are writing to the screen to a variable and then pipe that in to the export-csv.
    Wednesday, February 11, 2015 1:15 PM
  • Thank you sir.
    Wednesday, February 11, 2015 1:48 PM