Solved

need urgent assistance with powershell script to add variable.

Posted on 2016-07-25
3
52 Views
Last Modified: 2016-10-26
hello, can someone provide a way that we can feed this script with an input.csv

here is the logic:

New-AddressRewriteEntry -Name "<Descriptive Name>" -InternalAddress <internal email address> -ExternalAddress <external email address> [-OutboundOnly <$true | $false>]

Open in new window


i have a CSV with:
column 1 = internal email address
column 2 = external email address

need a way to define a variable so the script can reference the input CSV file and add these re-write entries for a list of users on the spreadsheet.

thanks in advance
0
Comment
Question by:siber1
  • 2
3 Comments
 
LVL 78

Accepted Solution

by:
David Johnson, CD, MVP earned 500 total points
Comment Utility
#input.csv header line
#descriptivename,InternalAddress,ExternalAddress,OutboundOnly
#Descriptive Rule,john.doe@machine.local,jdoe@example.com,
#Descriptive Rule2,john.smith@machine.local,jsmith@example.com,True
$infile = 'c:\test\input.csv'
$users = import-csv -path $infile
foreach($user in $users){
$outboundonly = $false
if ($user.OutboundOnly -eq 'true') { $outboundonly = $true }
New-AddressRewriteEntry -Name $user.Descriptive Name -InternalAddress $user.internalemailaddress -ExternalAddress $user.externalemailaddress -OutboundOnly $outboundonly
}

Open in new window

0
 

Author Comment

by:siber1
Comment Utility
excellent. just what we were looking for. thanks
0
 

Author Closing Comment

by:siber1
Comment Utility
trying to close out ticket again.
0

Featured Post

Do email signature updates give you a headache?

Constantly trying to correctly format email signatures? Spending all of your time at every user’s desk to make updates? Want high-quality HTML signatures on all devices, including on mobiles and Macs? Then, let Exclaimer solve all your email signature problems today!

Join & Write a Comment

Synchronize a new Active Directory domain with an existing Office 365 tenant
This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
In this video we show how to create a Shared Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Recipients >> Sha…
To show how to create a transport rule in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Rules tab.:  To cr…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now