cwstad2
asked on
powershell incorrect syntax
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.managem ent.powers hell.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.F qdn". 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 : CannotConvertArgumentNoMes sage,Micro soft.Excha nge.Manage ment.Syste mConfigura tionTasks. Ne
wReceiveConnector
function newrecieveconnector {
param
(
[Parameter(Mandatory=$true
[string]
$newrecieveconnector,
[Parameter(Mandatory=$true
[string]
$IPAddress,
[Parameter(Mandatory=$true
[string]
$subnet
)
add-pssnapin microsoft.exchange.managem
new-ReceiveConnector -Name 'Application Connector $newrecieveconnectorSMTP' -Usage 'Custom' -Bindings $IPAddress -Fqdn '$newrecieveconnectorSMTP.
}
error
New-ReceiveConnector : Cannot bind parameter 'Fqdn'. Cannot convert value "$newrecieveconnectorSMTP.
to type "Microsoft.Exchange.Data.F
"
At C:\it\Install Exchange2.ps1:191 char:119
+ new-ReceiveConnector -Name 'Application Connector $newrecieveconnectorSMTP' -Usage 'Custom' -Bindings $IPAddress -Fqd
n <<<< '$newrecieveconnectorSMTP.
+ CategoryInfo : InvalidArgument: (:) [New-ReceiveConnector], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMes
wReceiveConnector
ASKER
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,Mic rosoft.Exc hange.Mana gement.Sys temConfigu rationTask s.NewRecei ve
Connector
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.
+ CategoryInfo : WriteError: (:) [New-ReceiveConnector], ParameterBindingException
+ FullyQualifiedErrorId : ParameterBindingFailed,Mic
Connector
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
perfect thanks for the code, was almost there i think
ASKER
your a star, my head has been hurting with this ;')
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'
}
For example..
'Application Connector $newrecieveconnectorSMTP'
to
"Application Connector $newrecieveconnectorSMTP"
'$newrecieveconnector' to "$newrecieveconnector"
Open in new window