en:powershell:start
This is an old revision of the document!
PowerShell
Basics
According to me, the first thing we need to deal with is CSV file. First let's read one CSV file, loop over it.
Here is an example of CSV input file.
Samaccountname | |
---|---|
abc123 | abc123@domain.com |
def123 | def123@domain.com |
- input.csv
Samaccountname,Mail abc123,abc123@domain.com def123,def123@domain.com
- csv.ps1
Import-Csv -Path input.csv | foreach { # save current object into different variable $currentLine = $_ # deal with columns $sam = $currentLine.Samaccountname # let's see if the user exists into AD try { $user = Get-ADUser -identity $sam # user found } catch { # user not found, maybe user is disabled for instance ? } }
en/powershell/start.1615174302.txt.gz · Last modified: 2021/03/07 22:31 by lonclegr