Export-Csv doesn't mark -Path and -LiteralPath as mandatory, although Export-Clixml does
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 72/100
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
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
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
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de PowerShell/PowerShell
-
Issue-Enhancement Needs-Triage
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 86/100
PowerShell/PowerShell#28061 · 2 reações ·
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 90/100
PowerShell/PowerShell#28037 ·
-
Needs-Triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
PowerShell/PowerShell#27973 · 1 comentário ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
PowerShell/PowerShell#27720 ·
-
Issue-Bug Up-for-Grabs WG-Reviewed
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
PowerShell/PowerShell#27656 · 2 comentários ·
Todas as issues de PowerShell/PowerShell
Issues semelhantes
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
nightscout/nocturne#1425 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
RayWangQvQ/BiliBiliToolPro#1137 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100