PowerShell - Exploiter un fichier CSV
Par Romain Tiennot le mercredi 9 mai 2012, 10:36 - PowerShell - Lien permanent
Il est maintenant possible avec le Powershell d'exploiter des fichiers CSV très très facilement. Il gère aussi bien l'importation que l'exportation.
Voici un exemple d'un script Powershell qui :
- Importe un fichier CSV se trouvant dans le même répertoire que le que le script et il utilise le ";" pour séparer les informations
- Il va lire ligne par ligne et va créer automatiquement une variable par colonne. Dans mon exemple, j'ai deux colonnes. Une "prénom" et une "nom". Les variables sont "$User.prenom" et "$User.nom"
- Ensuite je vais créer une variable "$ident" qui sera l'identifiant des utilisateurs de l'AD (prenom.nom) puis il va désactiver les utilisateurs.
$Users = Import-Csv -Path ".\user.csv" -Delimiter ";" foreach ($User in $Users) { $ident = $User.prenom + "." + $User.nom Disable-ADAccount -Identity $ident }
A bientôt,
Romain
Il y a 4 commentaires
Bonjour,
Merci pour cet article court et efficace, ce que je cherchais =)
<<< We sometimes feel buffeted about by the forces of nature, relationships, family, children and more, and feel out of control of our own destinies. http://trinoitringoai.com/wp-includ... As a teenager, Bobby Gordon would go to Eddie Condon's jazz club in New York's Greenwich Village, sit at a table near the bandstand and nurse a Coke all night as he listened to such artists as Pee Wee Russell, Cutty Cutshall, Peanuts Hucko and Condon himself. http://viemdaitrang.com/wp-includes... B (Good) The ETF has a good track record for balancing performance with risk. Compared to other ETFs, it has achieved above average returns given the level of risk in its underlying investments.
Microdermabrasion can be a common cosmetic process
that's utilized to treat all kinds of skin problems.
Even so, due to their comfort and decreased costs, residence microdermabrasion creams
have turn into a well-known alternative to standard microdermabrasion.
ข้อมูลpackage AIS วันทูคอล
สุดฮิต โปรโมชันคนนิยมใช้ จาก เอไอเอส 12call
โปรโมชันเน็ตเสริมวันทูคอล โปรหลักเน็ตซิม AIS
12call