Solved

need urgent assistance with powershell script to add variable.

Posted on 2016-07-25
3
57 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
ID: 41728723
#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
ID: 41728734
excellent. just what we were looking for. thanks
0
 

Author Closing Comment

by:siber1
ID: 41744709
trying to close out ticket again.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
To show how to generate a certificate request 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 Servers >> Certificates…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…

910 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

22 Experts available now in Live!

Get 1:1 Help Now