I’m trying to check the schedule tasks on my servers, and I would like to use background-jobs and remote sessions to speed up the execution of the script.
But when i run my command in the remote session, the output is in a different culture ( or encoding ?) than onto my workstation.
I tried to use New-PsSessionOption but the result is the same :
-
locally run schtasks to check a remote server, output is OK :
PS>Get-Culture LCID Name DisplayName ---- ---- ----------- 1036 fr-FR French (France) PS>schtasks -s servername /v /query /fo csv |ConvertFrom-Csv |select -first 1 Nom de l'hôte : servername Nom de la tâche : \BITS_CCM_Incoming_{16 674A29-EDDD-43C3-9EF2- 2B2D64EFA6F5} Prochaine exécution : 23/11/2012 22:38:00 Statut : Prêt -
Open a remote session an run schtasks locally :
PS>$pso = New-PSSessionOption -Culture "fr-fr" PS>etsn servername -SessionOption $pso [servername]: PS C:\> get-culture LCID Name DisplayName ---- ---- ----------- 1036 fr-FR Français (France) [servername]: PS C:\> schtasks /query /v /fo csv |ConvertFrom-Csv |select -First 1 Nom de l'h"te : servername Nom de la tƒche : \BITS_CCM_Incoming_{16674A29-EDDD-43C3-9EF2-2B2D64EFA6F5} Prochaine ex'cution : 23/11/2012 22:38:00 Statut : Pr^t
as you can see deespite the same culture is used the output seems to be of different encondings. How to deal with that ?
After a while, I’ve found that I can use the COM object ‘Schedule.Service’ to retrieve tasks info wich is not language dependant :