Hello,
I am relatively new to Powershell and below is the script I have to create an AD contact so we can forward all users email to an external address. In Powershell ISE I get the below error. Can someone help me out with this please?
Missing closing '}' in statement block.
At line:17 char:13
import-module activedirectory
$contactlist = gc "C:\temp\contacts.csv"
foreach($line in $contactlist) {
$firstname = $line.split(",")[0]
$lastname = $line.split(",")[1]
$mail = $line.split(",")[2]
$mailnickname = $mail.Split("@")[0]
New-ADObject -Name "$firstname $lastname" -Type "Contact" -Path "fifesd.net/Network Support/Network Exchange Email to GMail contacts/" -DisplayName "$firstname $lastname" `
-OtherAttributes @{ sn=$lastname;
givenName=$firstname;
mail=$mail;
mailNickname=$mailnickname;
targetAddress="SMTP:$mail";
legacyExchangeDN="/o=ExchangeLabs/ou=Exchange Administrative Group/cn=Recipients/cn=$mailnickname";
mAPIRecipient=$false;
}