Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Import Source CSV
- $CSV = Import-CSV -Delimiter "," -Path c:\temp\users.csv
- #Loop to Create Active Directory Accounts
- Foreach ($r in $csv){
- #Manager Information
- If( ($($r.MFirst -like "")) -and ($($r.MLast -like "")) ){
- $MGRMess = "No Manager was entered"
- }
- Else{
- $Mdisplayname = "$($r.MLast)" + ", " + "$($r.MFirst)"
- $Msam = Get-ADUser -Filter {Name -eq $Mdisplayname} | Select -ExpandProperty SamAccountName
- If( ($Msam -eq $null) -or ($Msam -eq "") ){
- $MGRMess = "Could not find $Mdisplayname in Active Directory"
- }
- Else{
- $MGRMess = "Manager is $Mdisplayname/$Msam"
- }
- }
- Write-Output $MGRMess
Advertisement
Add Comment
Please, Sign In to add comment