Export-ScheduledTask : example 2 is inconsistent with actual behaviour

Aperta Adatta ai principianti
#4,112 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
75/100
Tipo di issue
Documentazione
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
powershell
Ambito
documentation

Direzione di ricerca

Apri docset/winserver2025-ps/ScheduledTasks/Export-ScheduledTask.md e analizza Example 2. Esegui la pipeline documentata in PowerShell sia con più attività sia con una singola attività, confrontando il comportamento riportato. Aggiorna l'esempio e le indicazioni correlate al file di output o alla codifica in modo che la documentazione corrisponda al comportamento supportato, quindi verifica l'esempio revisionato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

issue-doc-bug needs-triage
Prerequisites
  • Existing Issue: Search the existing issues for this repository. If there is an issue that fits your needs do not file a new one. Subscribe, react, or comment on that issue instead.
  • Descriptive Title: Write the title for this issue as a short synopsis. If possible, provide context. For example, "Typo in Get-Foo cmdlet" instead of "Typo."
  • Verify Version: If there is a mismatch between documentation and the behavior on your system, ensure that the version you are using is the same as the documentation. Check this box if they match or the issue you are reporting is not version specific.
Links
Summary

Example 2 shows:

Get-ScheduledTask -TaskPath "\UpdateTasks\" | Export-ScheduledTask

This implies that the cmdlet supports multiple pipeline input objects.

However, in practice, piping multiple tasks results in:

HRESULT 0x80070057 (The parameter is incorrect)
Details
Get-ScheduledTask -TaskPath '\Microsoft\Windows\Time Synchronization\' | Export-ScheduledTask 
....
Export-ScheduledTask : El parámetro no es correcto.
En línea: 1 Carácter: 74
+ ... ndows\Time Synchronization\' | Export-ScheduledTask -ErrorVariable kk
+                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (PS_ScheduledTask:Root/Microsoft/...S_ScheduledTask) [Export-ScheduledT
   ask], CimException
    + FullyQualifiedErrorId : HRESULT 0x80070057,Export-ScheduledTask

Seems it is not related to the collection:

Get-ScheduledTask -TaskPath '\Microsoft\Windows\Time Synchronization\' -TaskName ForceSynchronizeTime | Export-ScheduledTask
Export-ScheduledTask : El parámetro no es correcto.
En línea: 1 Carácter: 105
+ ... nchronization\' -TaskName ForceSynchronizeTime | Export-ScheduledTask
+                                                      ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (PS_ScheduledTask:Root/Microsoft/...S_ScheduledTask) [Export-ScheduledTask], CimException
    + FullyQualifiedErrorId : HRESULT 0x80070057,Export-ScheduledTask
Suggested Fix

Support -OutputPath to save scheduled task in a file

Document about how to use Out-File and/or the encoding necesary

Change the example to use

Get-ScheduledTask -TaskPath '\Microsoft\Windows\Time Synchronization\' | Foreach-Object {
            Export-ScheduledTask -TaskPath $_.taskpath -TaskName $_.taskname -ov "+tasks"
}  | Out-Null
Lingua principale
Dockerfile
Stelle
510
Fork
643
Merge medio
2g 21h
PR unite (30g)
8

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di MicrosoftDocs/windows-powershell-docs

Tutte le issue di MicrosoftDocs/windows-powershell-docs

Issue simili

Altre issue su Documentation

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.