locked
Possible error in Powershell Documentation - Export-Csv cmdlet RRS feed

  • Question


  • I have came across possible mistake in Powershell Help. It concerns  Export-Csv  cmdlet. In help file it stands as below: 

      -Path <String>
          Specifies the path to the CSV output file. This parameter is required.
    
          Required?                    false
          Position?                    1
          Default value                Current location
          Accept pipeline input?       false
          Accept wildcard characters?  false
    
    
    
    

    There is this parameter that is required then below it stands that "

    Required?                    false

    Which is true beacause the command may be run with specifing a path.

    Is it an error or is it  my misunderstanding of that matter?

    Thank you for your response.


    • Edited by mgiedyk Tuesday, October 25, 2016 7:32 AM
    Tuesday, October 25, 2016 7:23 AM

Answers

  • Export-CSv -LiteralPath c:\test/csv

    In this case Path is not used so it is not "Required".


    \_(ツ)_/

    • Proposed as answer by jrv Tuesday, October 25, 2016 2:15 PM
    • Marked as answer by Hello_2018 Wednesday, November 9, 2016 7:23 AM
    Tuesday, October 25, 2016 7:46 AM
  • If you run gci | export-csv , you will get an error that the cmdlet requires either -Path or -LiteralPath.  In this instance, the cmdlet looks for *either* of those parameters, but can only accept one of them.  They're mutually exclusive and can't both be marked as "required" in the cmdlet help.
    Tuesday, October 25, 2016 2:45 PM

All replies

  • Export-CSv -LiteralPath c:\test/csv

    In this case Path is not used so it is not "Required".


    \_(ツ)_/

    • Proposed as answer by jrv Tuesday, October 25, 2016 2:15 PM
    • Marked as answer by Hello_2018 Wednesday, November 9, 2016 7:23 AM
    Tuesday, October 25, 2016 7:46 AM
  • That is the point - i think there is a contradiction 

     -Path <String>
          Specifies the path to the CSV output file. This parameter is required.

    but then:

     Required?                    false

     


    Tuesday, October 25, 2016 8:32 AM
  • It is not required.  You do not have to use it.  If you use "LiteralPath" then you would not use "Path".  Think about this.  It is important to understand this logic and what the "Required" means.

    \_(ツ)_/

    Tuesday, October 25, 2016 2:15 PM
  • If you run gci | export-csv , you will get an error that the cmdlet requires either -Path or -LiteralPath.  In this instance, the cmdlet looks for *either* of those parameters, but can only accept one of them.  They're mutually exclusive and can't both be marked as "required" in the cmdlet help.
    Tuesday, October 25, 2016 2:45 PM