Solved

powershell incorrect syntax

Posted on 2013-02-06
6
1,109 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

A procedure for exporting installed hotfix details of remote computers using powershell
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 User 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 >> Mailb…
In this video we show how to create an Accepted Domain 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 >> Ac…

867 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

17 Experts available now in Live!

Get 1:1 Help Now