Export-ScheduledTask : example 2 is inconsistent with actual behaviour

Abierto Apto para principiantes
#4,112 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
75/100
Tipo de issue
Documentación
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
powershell

Línea de trabajo

Abra docset/winserver2025-ps/ScheduledTasks/Export-ScheduledTask.md e inspeccione Example 2. Ejecute la canalización documentada en PowerShell tanto con varias tareas como con una sola tarea y compare el comportamiento indicado. Actualice el ejemplo y las indicaciones relacionadas con el archivo de salida o la codificación para que la documentación coincida con el comportamiento compatible y, después, verifique el ejemplo revisado.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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
Lenguaje dominante
Dockerfile
Estrellas
510
Forks
643
Merge medio
2 d 21 h
PR fusionados (30 d)
8

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de MicrosoftDocs/windows-powershell-docs

Todos los issues de MicrosoftDocs/windows-powershell-docs

Issues similares

Más issues de Documentation

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.