Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

Export-Csv doesn't mark -Path and -LiteralPath as mandatory, although Export-Clixml does

Aberta Para iniciantes
#27,670 3 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
72/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Pouca atividade
Stack de tecnologia
csharp, powershell
Domínio
cli

Direção de pesquisa

Comece localizando as declarações de parâmetros de cmdlet de Export-Csv e Export-Clixml e compare seus atributos Path e LiteralPath. Reproduza os metadados dos parâmetros e os comandos de pipeline da issue e, em seguida, verifique se Export-Csv solicita um caminho quando nenhum dos dois parâmetros é fornecido e continua rejeitando o fornecimento de ambos.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

Issue-Bug Up-for-Grabs WG-Cmdlets WG-Reviewed
Prerequisites
Steps to reproduce

As in the title, neither -Path nor -LiteralPath is marked as mandatory for Export-Csv. This prevents the cmdlet from promting for a path if we do not provide one, even though a path is required for the cmdlet to run.

PS C:\Users\xyz> (Get-Command -Name Export-Csv).ImplementingType.GetProperty('Path').GetCustomAttributes([System.Management.Automation.ParameterAttribute])

ExperimentName                  :
ExperimentAction                : None
Position                        : 0
ParameterSetName                : __AllParameterSets
Mandatory                       : False
ValueFromPipeline               : False
ValueFromPipelineByPropertyName : False
ValueFromRemainingArguments     : False
HelpMessage                     :
HelpMessageBaseName             :
HelpMessageResourceId           :
DontShow                        : False
TypeId                          : System.Management.Automation.ParameterAttribute

TypeId : System.Management.Automation.ValidateNotNullOrEmptyAttribute

PS C:\Users\xyz> (Get-Command -Name Export-Csv).ImplementingType.GetProperty('LiteralPath').GetCustomAttributes([System.Management.Automation.ParameterAttribute])

ExperimentName                  :
ExperimentAction                : None
Position                        : -2147483648
ParameterSetName                : __AllParameterSets
Mandatory                       : False
ValueFromPipeline               : False
ValueFromPipelineByPropertyName : False
ValueFromRemainingArguments     : False
HelpMessage                     :
HelpMessageBaseName             :
HelpMessageResourceId           :
DontShow                        : False
TypeId                          : System.Management.Automation.ParameterAttribute

TypeId : System.Management.Automation.ValidateNotNullOrEmptyAttribute

AliasNames : {PSPath, LP}
TypeId     : System.Management.Automation.AliasAttribute

Export-Clixml for comparison

PS C:\Users\xyz> (Get-Command -Name Export-Clixml).ImplementingType.GetProperty('Path').GetCustomAttributes([System.Management.Automation.ParameterAttribute])

ExperimentName                  :
ExperimentAction                : None
Position                        : 0
ParameterSetName                : ByPath
Mandatory                       : True
ValueFromPipeline               : False
ValueFromPipelineByPropertyName : False
ValueFromRemainingArguments     : False
HelpMessage                     :
HelpMessageBaseName             :
HelpMessageResourceId           :
DontShow                        : False
TypeId                          : System.Management.Automation.ParameterAttribute

PS C:\Users\xyz> (Get-Command -Name Export-Clixml).ImplementingType.GetProperty('LiteralPath').GetCustomAttributes([System.Management.Automation.ParameterAttribute])

ExperimentName                  :
ExperimentAction                : None
Position                        : -2147483648
ParameterSetName                : ByLiteralPath
Mandatory                       : True
ValueFromPipeline               : False
ValueFromPipelineByPropertyName : False
ValueFromRemainingArguments     : False
HelpMessage                     :
HelpMessageBaseName             :
HelpMessageResourceId           :
DontShow                        : False
TypeId                          : System.Management.Automation.ParameterAttribute

AliasNames : {PSPath, LP}
TypeId     : System.Management.Automation.AliasAttribute

PS C:\Users\xyz\Desktop> $results = get-process -Name pwsh*
PS C:\Users\xyz\Desktop> $results | export-clixml

cmdlet Export-Clixml at command pipeline position 1
Supply values for the following parameters:
Path: results.xml
PS C:\Users\xyz\Desktop>
Expected behavior
PS C:\Users\xyz\Desktop> $results = get-process -Name pwsh*
PS C:\Users\xyz\Desktop> $results | export-csv

cmdlet Export-Csv at command pipeline position 1
Supply values for the following parameters:
Path: results.csv
PS C:\Users\xyz\Desktop>
Actual behavior
PS C:\Users\xyz\Desktop> $results = get-process -Name pwsh*
PS C:\Users\xyz\Desktop> $results | export-csv
Export-Csv: You must specify either the -Path or -LiteralPath parameters, but not both.
PS C:\Users\xyz\Desktop>
Error details

Environment data
Name                           Value
----                           -----
PSVersion                      7.6.3
PSEdition                      Core
GitCommitId                    7.6.3
OS                             Microsoft Windows 10.0.26200
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.4
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Visuals

No response

Linguagem predominante
C#
Estrelas
55.5k
Forks
8.5k
Merge médio
1d 17h
PRs com merge (30d)
97

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de PowerShell/PowerShell

Todas as issues de PowerShell/PowerShell

Issues semelhantes

Mais issues de C#

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.