Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $FirstName = @()
- $LastName = @()
- $liny = ""
- foreach($line in Get-Content .\userList.txt) #.\userList.txt
- {
- $UC = ""
- $LC = ""
- $strtab = $line -split "\s+"
- for($i=0; $i -lt $strtab.length; $i++)
- {
- if($strtab[$i] -cmatch "[A-Z]{2,}")
- {
- if($UC -eq "")
- {
- $UC = $strtab[$i]
- }
- else
- {
- $UC += " " + $strtab[$i]
- }
- }
- else
- {
- if($LC -eq "")
- {
- $LC = $strtab[$i]
- }
- else
- {
- $LC += " " + $strtab[$i]
- }
- }
- }
- $FirstName += $LC
- $LastName += $UC
- }
- #0..($FirstName.Length-1) | Select-Object @{n="FirstName";e={$FirstName[$_]}}, @{n="LastName";e={$LastName[$_]}} #display 2 dim tab of name & surname
- for($i=0; $i -lt ($FirstName.Length-1); $i++)
- {
- $theUser = Get-ADUser -SearchBase "ou=SAM,dc=mydom,dc=dom,dc=fr" -Properties mail -Filter * `
- | ? { $_.SurName -eq $LastName[$i] -and $_.GivenName -eq $FirstName[$i]} | select -Property mail, GivenName, Surname
- $liny += $theUser.mail + " " + $theUser.GivenName + " " + $theUser.SurName + "`n"
- }
- $liny | Out-File ".\userListFormated.txt"
- $liny
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement