« PowerShell/Active Directory » : différence entre les versions
Aller à la navigation
Aller à la recherche
(Page créée avec « {{Sommaire}} == Script de mise à jour d'Active Directory == === Lire les lignes d'un fichier === Avec le fichier suivant <code>C:\tmp\source.csv</code> : <pre> compte;civilité;nom;prénom;société;service dupondp;M.;Dupond;Pierre;MaSociété;SI martinj;M.;Martin;Jean;MaSociété;Commercial defrattec;Mme;De Fratte;Catherine;MaSociété;Export </pre> Premier script : <source> $fichier = Import-Csv "C:\tmp\source.csv" -Delimiter ";" Foreach ($ligne in $fichier) {... ») |
mAucun résumé des modifications |
||
Ligne 36 : | Ligne 36 : | ||
Mme De Fratte appartient au service Export | Mme De Fratte appartient au service Export | ||
</pre> | </pre> | ||
== PowerShell and Active Directory Essentials == | |||
Vidéo Youtube, Varonis, PowerShell and Active Directory Essentials | |||
* https://www.youtube.com/watch?v=-zDXTLiX_wk | |||
* durée : 5 h 02 | |||
== Voir aussi == | == Voir aussi == | ||
* | * |
Version du 3 octobre 2023 à 00:00
Script de mise à jour d'Active Directory
Lire les lignes d'un fichier
Avec le fichier suivant C:\tmp\source.csv
:
compte;civilité;nom;prénom;société;service dupondp;M.;Dupond;Pierre;MaSociété;SI martinj;M.;Martin;Jean;MaSociété;Commercial defrattec;Mme;De Fratte;Catherine;MaSociété;Export
Premier script :
$fichier = Import-Csv "C:\tmp\source.csv" -Delimiter ";" Foreach ($ligne in $fichier) { Write-Host $ligne }
Le résultat du premier script est :
@{compte=dupondp; nom=Dupond; prénom=Pierre; société=MaSociété; service=SI} @{compte=martinj; nom=Martin; prénom=Jean; société=MaSociété; service=Commercial} @{compte=defrattec; nom=De Fratte; prénom=Catherine; société=MaSociété; service=Export}
Deuxième script :
Import-Csv "C:\tmp\source.csv" -Delimiter ";" | Foreach { Write-Host ("{0} {1} appartient au service {2}" -f $_.civilité, $_.nom, $_.service) }
Le résultat du deuxième script est :
M. Dupond appartient au service SI M. Martin appartient au service Commercial Mme De Fratte appartient au service Export
PowerShell and Active Directory Essentials
Vidéo Youtube, Varonis, PowerShell and Active Directory Essentials
- https://www.youtube.com/watch?v=-zDXTLiX_wk
- durée : 5 h 02