« PowerShell/Données » : différence entre les versions
Aller à la navigation
Aller à la recherche
(Page créée avec « {{Sommaire}} La gestion de données avec PowerShell. Site de référence : * https://www.techthoughts.info Page concernant le sujet des données : * https://www.techthoughts.info/powershell-input-output == Données au format JSON == Vidéo Youtube, TechThoughts, PowerShell Input & Output * https://www.youtube.com/watch?v=nnTlsNA3hPk&t=30s == Données issues d'un journal (log) == Vidéo Youtube, TechThoughts, PowerShell Input & Output * https://www.youtube.c... ») |
|||
(Une version intermédiaire par le même utilisateur non affichée) | |||
Ligne 12 : | Ligne 12 : | ||
Vidéo Youtube, TechThoughts, PowerShell Input & Output | Vidéo Youtube, TechThoughts, PowerShell Input & Output | ||
* https://www.youtube.com/watch?v=nnTlsNA3hPk&t=30s | * https://www.youtube.com/watch?v=nnTlsNA3hPk&t=30s | ||
DelfStack, page principale sur PowerShell : | |||
* https://www.delftstack.com/howto/powershell | |||
DelfStack, pages sur JSON | |||
* créer un fichier JSON : | |||
** https://www.delftstack.com/howto/powershell/powershell-json-array/ | |||
* autres applications : | |||
** https://www.delftstack.com/howto/powershell/parsing-json-files-using-powershell/ | |||
** https://www.delftstack.com/howto/powershell/powershell-loop-through-json/ | |||
== Exemple == | |||
Liste de comptes | |||
<source> | |||
# liste de comptes | |||
$Compte = @( | |||
[pscustomobject]@{Nom = "Pierre"; Courriel = "pierre@pierre.fr"} | |||
[pscustomobject]@{Nom = "Paul"; Courriel = "paul@paul.fr"} | |||
[pscustomobject]@{Nom = "Jacques"; Courriel = "jacques@jacques.bzh"} | |||
) | |||
$Compte | |||
</source> | |||
Résultat : | |||
<pre> | |||
Nom Courriel | |||
--- -------- | |||
Pierre pierre@pierre.fr | |||
Paul paul@paul.fr | |||
Jacques jacques@jacques.bzh | |||
</pre> | |||
Avec conversion au format JSON : | |||
<source> | |||
# liste de comptes | |||
$Compte = @( | |||
[pscustomobject]@{Nom = "Pierre"; Courriel = "pierre@pierre.fr"} | |||
[pscustomobject]@{Nom = "Paul"; Courriel = "paul@paul.fr"} | |||
[pscustomobject]@{Nom = "Jacques"; Courriel = "jacques@jacques.bzh"} | |||
) | |||
$Compte | ConvertTo-Json | |||
</source> | |||
Résultat : | |||
<pre> | |||
[ | |||
{ | |||
"Nom": "Pierre", | |||
"Courriel": "pierre@pierre.fr" | |||
}, | |||
{ | |||
"Nom": "Paul", | |||
"Courriel": "paul@paul.fr" | |||
}, | |||
{ | |||
"Nom": "Jacques", | |||
"Courriel": "jacques@jacques.bzh" | |||
} | |||
] | |||
</pre> | |||
== Données issues d'un journal (log) == | == Données issues d'un journal (log) == |
Dernière version du 23 février 2024 à 22:31
La gestion de données avec PowerShell.
Site de référence :
Page concernant le sujet des données :
Données au format JSON
Vidéo Youtube, TechThoughts, PowerShell Input & Output
DelfStack, page principale sur PowerShell :
DelfStack, pages sur JSON
- créer un fichier JSON :
- autres applications :
Exemple
Liste de comptes
# liste de comptes $Compte = @( [pscustomobject]@{Nom = "Pierre"; Courriel = "pierre@pierre.fr"} [pscustomobject]@{Nom = "Paul"; Courriel = "paul@paul.fr"} [pscustomobject]@{Nom = "Jacques"; Courriel = "jacques@jacques.bzh"} ) $Compte
Résultat :
Nom Courriel --- -------- Pierre pierre@pierre.fr Paul paul@paul.fr Jacques jacques@jacques.bzh
Avec conversion au format JSON :
# liste de comptes $Compte = @( [pscustomobject]@{Nom = "Pierre"; Courriel = "pierre@pierre.fr"} [pscustomobject]@{Nom = "Paul"; Courriel = "paul@paul.fr"} [pscustomobject]@{Nom = "Jacques"; Courriel = "jacques@jacques.bzh"} ) $Compte | ConvertTo-Json
Résultat :
[ { "Nom": "Pierre", "Courriel": "pierre@pierre.fr" }, { "Nom": "Paul", "Courriel": "paul@paul.fr" }, { "Nom": "Jacques", "Courriel": "jacques@jacques.bzh" } ]
Données issues d'un journal (log)
Vidéo Youtube, TechThoughts, PowerShell Input & Output
Données au format CSV
Vidéo Youtube, TechThoughts, PowerShell Input & Output