So that works when adding an IP address (thank you!), however, I receive
the following when attempting to remove an IP address (using -=):








*Method invocation failed because [System.Collections.ArrayList] doesn't
contain a method named 'op_Subtraction'.At J:\MIS Technical
Support\Distributed\Continuity\Continuity Binders\Scripting\Exchange
2010\SMTPRelay\DoNotExecute\RemoveFromRelayList.ps1:92 char:29+
$RecvConn.RemoteIPRanges -= <<<<  $HostIPConv    + CategoryInfo          :
InvalidOperation: (op_Subtraction:String) [], Ru   ntimeException    +
FullyQualifiedErrorId : MethodNotFound*

- Sean

On Thu, Dec 4, 2014 at 2:54 PM, Michael B. Smith <[email protected]>
wrote:

>  Hmmmm.
>
>
>
> Willing to try something else?  Try this…
>
>
>
> $RecvConns = Get-ReceiveConnector | where {$_.name -eq "SMTP Relay
> Connector"}
>
>
>
> forEach ($recvConn in $recvConns) {
>
> Write-Host "Updating", $recvConn.Identity
>
> $RecvConn.RemoteIPRanges += $HostIPConv
>
> $recvConn.Guid.ToString() | Set-ReceiveConnector -RemoteIPRanges
> $RecvConn.RemoteIPRanges
>
> }
>
>
>
> *From:* [email protected] [mailto:
> [email protected]] *On Behalf Of *Sean Martin
> *Sent:* Thursday, December 4, 2014 6:13 PM
> *To:* [email protected]
> *Subject:* Re: [Exchange] PowerShell Help
>
>
>
> Thanks for the tip on the operator, that does make better sense.
>
>
>
> Unfortunately I'm still encountering a similar issue:
>
>
>
> *Cannot process argument transformation on parameter 'Identity'. Cannot
> convert*
>
>
>
>
>
> * the "b1645fd1-31c2-46f0-9df6-36cb7285303b" value of type "System.Guid"
> to type
> "Microsoft.Exchange.Configuration.Tasks.ReceiveConnectorIdParameter".     +
> CategoryInfo          : InvalidData: (:) [Set-ReceiveConnector], Paramet
> erBindin...mationException     + FullyQualifiedErrorId :
> ParameterArgumentTransformationError,Set-Receive    Connector*
>
>
>
> On Thu, Dec 4, 2014 at 1:47 PM, Michael B. Smith <[email protected]>
> wrote:
>
> This should sort it. As an aside, you should probably be using “-eq”
> instead of “-match”, if only one connector is supposed to match.
>
>
>
> $RecvConns = Get-ReceiveConnector | where {$_.name -match "SMTP Relay
> Connector"}
>
>
> forEach ($recvConn in $recvConns) {
>  Write-Host "Updating", $recvConn.Identity
>  $RecvConn.RemoteIPRanges += $HostIPConv
>  Set-ReceiveConnector –Identity $recvConn.Guid -RemoteIPRanges
> $RecvConn.RemoteIPRanges
> }
>
>
>
>
>
> *From:* [email protected] [mailto:
> [email protected]] *On Behalf Of *Sean Martin
> *Sent:* Thursday, December 4, 2014 3:47 PM
> *To:* [email protected]
> *Subject:* [Exchange] PowerShell Help
>
>
>
> Good morning/afternoon,
>
>
>
> I need a little assistance with a PS script I'm putting together. Just to
> let it be known, scripting is not my strong suit.
>
>
>
> I'm putting together a powershell script for Junior admins to quickly and
> efficiently add or remove IP addresses to a relay connector we have on our
> Exchange servers. The entire script accepts input from the user, does some
> connectivity checks, dns checks, etc. but the primary function is to gather
> the input and simply run the set-receiveconnector cmdlet with the updated
> IP list. When I execute the script from the Exchange Management shell, it
> works perfectly. However, I would like the admins to be able to execute the
> script quickly and easily, and potentially from a PC that doesn't have the
> EMS installed.
>
>
> Here's the code that works when the script is executed from the EMS:
>
>
>
> ================================================================
>
> $RecvConns = Get-ReceiveConnector | where {$_.name -match "SMTP Relay
> Connector"}
>
>
> forEach ($recvConn in $recvConns) {
>  Write-Host "Updating", $recvConn.Identity
>  $RecvConn.RemoteIPRanges += $HostIPConv
>  Set-ReceiveConnector $recvConn -RemoteIPRanges $RecvConn.RemoteIPRanges
> }
>
> ================================================================
>
>
>
> However, if I add the logic to import a PSsession so the user can simply
> right-click and execute in powershell:
>
>
>
> ================================================================
>
> $ExchSrvr = "server1","server2","server3" | Where {Test-Connection
> -ComputerName $_ -Count 1 -Quiet} | Get-Random
> $ExchSess = New-PSSession -ConfigurationName Microsoft.Exchange
> -ConnectionUri ("http://{0}.<domain>/PowerShell" -f $exchsrvr)
> Import-PSSession $ExchSess
>
> ================================================================
>
>
>
> I receive this error when the script attemps to set-receiveconnector:
>
>
>
> *Cannot process argument transformation on parameter 'Identity'. Cannot
> convert*
>
>
>
>
>
>
> * the "<servername>\SMTP Relay Connector" value of type
> "Deserialized.Microsoft.Exchan
> ge.Data.Directory.SystemConfiguration.ReceiveConnector" to type
> "Microsoft.Exch ange.Configuration.Tasks.ReceiveConnectorIdParameter".
> + CategoryInfo          : InvalidData: (:) [Set-ReceiveConnector], Paramet
>    erBindin...mationException     + FullyQualifiedErrorId :
> ParameterArgumentTransformationError,Set-Receive    Connector*
>
>
>
>
>
> I'm having a hard time tracking this issue down. Please note I removed
> references to actual server names and domains. The actual script is in the
> proper syntax. Appreciate any help anyone can provide.
>
>
>
> - Sean
>
>
>
>
>

Reply via email to