Question
Résultat d'une commande dans un mail
- Philippe
- Hors Ligne
- Modérateur
-
- Messages : 1778
- Remerciements reçus 21
en faite je pense qu'on a tous faux tout les deux LaurentCe n'est pas nécessaire avec cet opérateur.
Vérifie si tes données à formater sont correctes
si tu regarde bien, gregmurf à repris une partie du debut du script du premier post et la mis a la suite de Invoke-SshCommand mais je pense que Invoke-SshCommand renvoie une chaine de caractères et non un objet et encore moins un objet System.Management.ManagementObject#root\cimv2\Win32_LogicalDisk
il va donc falloir joué avec du regex et du split pour filtré les données !!!
Connexion ou Créer un compte pour participer à la conversation.
- Philippe
- Hors Ligne
- Modérateur
-
- Messages : 1778
- Remerciements reçus 21
peut tu nous confirmé en renvoyent ce que donne la command Invoke-SshCommand
en fassent par exemple :
[code:1]Invoke-SshCommand -index 0 -Command \"df -h\" | Get-Member[/code:1]avec le new-sshsessions avant bien sur
Connexion ou Créer un compte pour participer à la conversation.
- xyz
- Hors Ligne
- Modérateur
-
- Messages : 6311
- Remerciements reçus 69
Je donnais juste une piste, car si ce n'est pas le code qui pose pb, il faut regarder du côté des données.en faite je pense qu'on a tous faux tout les deux Laurent
Je ne connais pas ce cmdlet et je n'ai pas de serveur de test Linux...
Tutoriels PowerShell
Connexion ou Créer un compte pour participer à la conversation.
- Toper
- Auteur du sujet
- Hors Ligne
- Membre premium
-
- Messages : 145
- Remerciements reçus 0
6ratgus écrit:
gregmurf a tu compris mon précèdent post ?
peut tu nous confirmé en renvoyent ce que donne la command Invoke-SshCommand
Oui, j'ai compris et c'est ce que je \"craignais\".
en fassent par exemple :
[code:1]Invoke-SshCommand -index 0 -Command \"df -h\" | Get-Member[/code:1]avec le new-sshsessions avant bien sur
[code:1]New-SshSession -ComputerName server -Username user -Password pwd
Invoke-SshCommand -ComputerName server -Command \"df -h\" | get-member[/code:1]
Voici ce qu'elle renvoi:
TypeName : System.Object[]
Name MemberType Definition
----
Count AliasProperty Count = Length
Add Method int IList.Add(System.Object value)
Address Method System.Object&, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Address(int )
Clear Method void IList.Clear()
Clone Method System.Object Clone(), System.Object ICloneable.Clone()
CompareTo Method int IStructuralComparable.CompareTo(System.Object other, System.Collections.IComparer comparer)
Contains Method bool IList.Contains(System.Object value)
CopyTo Method void CopyTo(array array, int index), void CopyTo(array array, long index), void ICollection.CopyTo(array array, int index)
Equals Method bool Equals(System.Object obj), bool IStructuralEquatable.Equals(System.Object other, System.Collections.IEqualityComparer comparer)
Get Method System.Object Get(int )
GetEnumerator Method System.Collections.IEnumerator GetEnumerator(), System.Collections.IEnumerator IEnumerable.GetEnumerator()
GetHashCode Method int GetHashCode(), int IStructuralEquatable.GetHashCode(System.Collections.IEqualityComparer comparer)
GetLength Method int GetLength(int dimension)
GetLongLength Method long GetLongLength(int dimension)
GetLowerBound Method int GetLowerBound(int dimension)
GetType Method type GetType()
GetUpperBound Method int GetUpperBound(int dimension)
GetValue Method System.Object GetValue(Params int[] indices), System.Object GetValue(int index), System.Object GetValue(int index1, int index2), System.Objec...
IndexOf Method int IList.IndexOf(System.Object value)
Initialize Method void Initialize()
Insert Method void IList.Insert(int index, System.Object value)
Remove Method void IList.Remove(System.Object value)
RemoveAt Method void IList.RemoveAt(int index)
Set Method void Set(int , System.Object )
SetValue Method void SetValue(System.Object value, int index), void SetValue(System.Object value, int index1, int index2), void SetValue(System.Object value,...
ToString Method string ToString()
Item ParameterizedProperty System.Object IList.Item(int index) {get;set;}
IsFixedSize Property bool IsFixedSize {get;}
IsReadOnly Property bool IsReadOnly {get;}
IsSynchronized Property bool IsSynchronized {get;}
Length Property int Length {get;}
LongLength Property long LongLength {get;}
Rank Property int Rank {get;}
SyncRoot Property System.Object SyncRoot {get;}
Message édité par: gregmurf, à: 27/02/15 13:12<br><br>Message édité par: gregmurf, à: 27/02/15 13:15
Powershell: la vie est belle
Connexion ou Créer un compte pour participer à la conversation.
- Toper
- Auteur du sujet
- Hors Ligne
- Membre premium
-
- Messages : 145
- Remerciements reçus 0
Pièces jointes :
Connexion ou Créer un compte pour participer à la conversation.
- xyz
- Hors Ligne
- Modérateur
-
- Messages : 6311
- Remerciements reçus 69
Essaie ceci :
[code:1]
Invoke-SshCommand -index 0 -Command \"df -h\" |
group-object -Property {$_.gettype()}
[/code:1]
Tutoriels PowerShell
Connexion ou Créer un compte pour participer à la conversation.
- Vous êtes ici :
-
Accueil
-
forum
-
PowerShell
-
Entraide pour les débutants
- Résultat d'une commande dans un mail