Question [Résolu] Récupérer résultats compare-object...

Plus d'informations
il y a 15 ans 1 jour #9676 par Norris Chuck
Amis scripteurs, bonjour !

je rencontre un soucis : je voudrais récupérer les résulats de la commande suivante dans une variable afin de pouvoir la manipuler.

[code:1]
$error_msg = compare-object -referenceobject $(get-content C:\error_OK.txt) -differenceobject $(get-content C:\error_KO.txt) | Format-table -property InputObject -HideTableHeaders)[/code:1]

Seulement, je ne récupère pas la chaine de caractère :

[code:1]PS C:\WINDOWS\system32\windowspowershell\v1.0> Write-Host $error_msg
Microsoft.PowerShell.Commands.Internal.Format.FormatStartData Microsoft.PowerShe
ll.Commands.Internal.Format.GroupStartData Microsoft.PowerShell.Commands.Interna
l.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.FormatEnt
ryData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.P
owerShell.Commands.Internal.Format.GroupEndData Microsoft.PowerShell.Commands.In
ternal.Format.FormatEndData[/code:1]

J'ai parcouru Internet sans trouver de solution adaptable à mon problème.

Merci par avance de votre aide.

Fabien.<br><br>Message édité par: befadudesert, à: 19/05/11 16:28

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 15 ans 1 jour #9677 par xyz
Salut,
befadudesert écrit:

Seulement, je ne récupère pas la chaine de caractère

Si si tu récupères bien ton résultat, mais formaté.
La suppression de l'appel à Format-Table devrait résoudre une partie de ton pb, car l'autre pb, un piège plutôt, est que le cmdlet Compare-Object utilise une \&quot;fenêtre de synchronisation\&quot; lors des comparaisons, voir ce post .<br><br>Message édité par: Laurent Dardenne, à: 18/05/11 19:59

Tutoriels PowerShell

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 15 ans 1 jour #9679 par Norris Chuck
Merci de ta réponse Laurent,

en ayant le nez collé sur le problème je n'ai pas vu le soucis de Format-Table.

Reste plus qu'à mettre en forme la sortie, je vous tiens au courant quand j'aurais une sortie propre !

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 15 ans 19 heures #9683 par Norris Chuck
Ca fonctionne mieux avec l'option PassThru :

[code:1]$error_msg = compare-object -referenceobject $(get-content C:\error_OK.txt) -differenceobject $(get-content C:\error_KO.txt) -PassThru[/code:1]

Connexion ou Créer un compte pour participer à la conversation.

Temps de génération de la page : 0.039 secondes
Propulsé par Kunena