Solved

powershell incorrect syntax

Posted on 2013-02-06
6
1,154 Views
Last Modified: 2013-02-06
Hi guys i have applied the same principle to a previous question i had raised but im getting stuck. Ive tried multiple ways but enough is enough. i run the following function and get the error below. Thanks guys

function newrecieveconnector {
      param
      (
      [Parameter(Mandatory=$true,Position=0)]
      [string]
      $newrecieveconnector,
      [Parameter(Mandatory=$true,Position=1)]
      [string]
      $IPAddress,
      [Parameter(Mandatory=$true,Position=2)]
      [string]
      $subnet
      )
add-pssnapin microsoft.exchange.management.powershell.e201
new-ReceiveConnector -Name 'Application Connector $newrecieveconnectorSMTP' -Usage 'Custom' -Bindings $IPAddress -Fqdn '$newrecieveconnectorSMTP.lime.corp.com' -RemoteIPRanges $subnet -Server '$newrecieveconnector'
}


error

New-ReceiveConnector : Cannot bind parameter 'Fqdn'. Cannot convert value "$newrecieveconnectorSMTP.lime.corp.com"
to type "Microsoft.Exchange.Data.Fqdn". Error: ""$newrecieveconnectorSMTP.lime.corp.com" isn't a valid SMTP domain.
"
At C:\it\Install Exchange2.ps1:191 char:119
+ new-ReceiveConnector -Name 'Application Connector $newrecieveconnectorSMTP' -Usage 'Custom' -Bindings $IPAddress -Fqd
n <<<<  '$newrecieveconnectorSMTP.lime.corp.com' -RemoteIPRanges $subnet -Server '$newrecieveconnector'
    + CategoryInfo          : InvalidArgument: (:) [New-ReceiveConnector], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.Exchange.Management.SystemConfigurationTasks.Ne
   wReceiveConnector
0
Comment
Question by:cwstad2
  • 3
  • 2
6 Comments
 
LVL 40

Expert Comment

by:Subsun
ID: 38859143
Change single quotes to double quotes, single quotes wont expand the VAR..

For example..

'Application Connector $newrecieveconnectorSMTP'  

to

"Application Connector $newrecieveconnectorSMTP"

'$newrecieveconnector' to "$newrecieveconnector"

function newrecieveconnector {
      param
      (
      [Parameter(Mandatory=$true,Position=0)]
      [string]
      $newrecieveconnector,
      [Parameter(Mandatory=$true,Position=1)]
      [string]
      $IPAddress,
      [Parameter(Mandatory=$true,Position=2)]
      [string]
      $subnet
      )
new-ReceiveConnector -Name "Application Connector $($newrecieveconnector)SMTP" -Usage 'Custom' -Bindings $IPAddress -Fqdn "$($newrecieveconnector)SMTP.lime.corp.com" -RemoteIPRanges $subnet -Server "$newrecieveconnector"
}

Open in new window

0
 
LVL 15

Author Comment

by:cwstad2
ID: 38859163
Hi I tried that previously get this when i add the ""

New-ReceiveConnector : Cannot bind parameter 'Name' to the target. Exception setting "Name": "The property value is inv
alid. The value can't contain leading or trailing whitespace."
At C:\it\Install Exchange2.ps1:191 char:27
+ new-ReceiveConnector -Name <<<<  "Application Connector $newrecieveconnectorSMTP" -Usage 'Custom' -Bindings $IPAddres
s -Fqdn "$newrecieveconnectorSMTP.lime.corp.com" -RemoteIPRanges $subnet -Server "$newrecieveconnector"
    + CategoryInfo          : WriteError: (:) [New-ReceiveConnector], ParameterBindingException
    + FullyQualifiedErrorId : ParameterBindingFailed,Microsoft.Exchange.Management.SystemConfigurationTasks.NewReceive
   Connector
0
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 38859168
Did you try the code which I posted?
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
LVL 15

Author Comment

by:cwstad2
ID: 38859178
perfect thanks for the code, was almost there i think
0
 
LVL 15

Author Closing Comment

by:cwstad2
ID: 38859182
your a star, my head has been hurting with this ;')
0
 
LVL 37

Expert Comment

by:Neil Russell
ID: 38859188
Try

function newrecieveconnector {
      param
      (
      [Parameter(Mandatory=$true,Position=0)]
      [string]
      $newrecieveconnector,
      [Parameter(Mandatory=$true,Position=1)]
      [string]
      $IPAddress,
      [Parameter(Mandatory=$true,Position=2)]
      [string]
      $subnet
      )
add-pssnapin microsoft.exchange.management.powershell.e201

$Name = "'Application Connector $newrecieveconnector" + "SMTP"
$fqdn = $newrecieveconnector + "SMTP.lime.corp.com"

new-ReceiveConnector -Name $Name -Usage 'Custom' -Bindings $IPAddress -Fqdn $fqdn -RemoteIPRanges $subnet -Server '$newrecieveconnector'
}

Open in new window

0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Multiple SSL on Exchange 2010 3 25
Unified EndPoint Management 1 25
exchange, email gateway 2 29
. .\Variables.ps1 returning CommandNotFound 2 13
Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
Find out what you should include to make the best professional email signature for your organization.
In this video we show how to create a Contact 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 >> Contact ta‚Ķ
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‚Ķ

770 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