Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows_task is not portable on different locales #6843

Open
standard3 opened this issue Nov 2, 2023 · 0 comments
Open

windows_task is not portable on different locales #6843

standard3 opened this issue Nov 2, 2023 · 0 comments

Comments

@standard3
Copy link

Describe the problem

In the definition of the windows_task resource, it uses schtasks instead of Powershell so if our system isn't in English, the parsed attributes become unusable :

script = "schtasks /query /v /fo csv /tn '#{@taskuri}' | ConvertFrom-Csv | Select @{N='URI';E={$_.TaskName}},@{N='State';E={$_.Status.ToString()}},'Logon Mode','Last Result','Task To Run','Run As User','Scheduled Task State' | ConvertTo-Json -Compress"

For example, on my French system, the partial command looks like :

PS C:\Users\my_user> schtasks /query /v /fo csv /tn '\my\task\path' | ConvertFrom-Csv

Nom de l'hôte                                             : my-host-name
Nom de la tâche                                           : \my\task\path
Prochaine exécution                                       : Redacted
Statut                                                    : Redacted
Mode d'ouverture de session                               : Redacted
Heure de la dernière exécution                            : Redacted
Dernier résultat                                          : Redacted
Auteur                                                    : Redacted
Tâche à exécuter                                          : Redacted
Démarrer dans                                             : Redacted
Commentaire                                               : Redacted
Statut de la tâche planifiée                              : Redacted
Durée d'inactivité                                        : Redacted
Gestion de l'alimentation                                 : Redacted
Exécuter en tant qu'utilisateur                           : Redacted
Supprimer la tâche si elle n'est pas replanifiée          : Redacted
Arrêter la tâche après X heures et X minutes              : Redacted
Planification                                             : Redacted
Type de planification                                     : Redacted
Heure de début                                            : Redacted
Date de début                                             : Redacted
Date de fin                                               : Redacted
Jours                                                     : Redacted
Mois                                                      : Redacted
Répéter : Chaque                                          : Redacted
Répéter : Jusqu'à : Heure                                 : Redacted
Répétition : pendant une durée donnée                     : Redacted
Répétition : arrêter si l'exécution est toujours en cours : Redacted

You can clearly that attributes names do not match Inspec ones at all. If I continue executing the command, just trying to get the scheduled task URI then nothing appears.

PS C:\Users\my_user> schtasks /query /v /fo csv /tn '\my\task\path' | ConvertFrom-Csv | Select @{N='URI';E={$_.TaskName}}

URI
---

So my scheduled task exists but Inspec can't see it because of the used command.

Possible Solution

Maybe use Get-ScheduledTask instead of schtasks to be more portable.
Reading the code, apparently this solution was already present before but was removed to be backward compatible. I can't think of any alternatives with the actual method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant