dsccommunity/ExchangeDsc

Resource Proposal: xExchSendConnector

nimsim opened this issue · 14 comments

Hi,
This might not be that relevant, but I'm a bit surprised there is no xSendConnector resource. Am i blind, or is there really no SendConnector?

I see a previous issue here
with a somewhat weird ending.

I don't have any plans to work on this, and I'm not aware of anyone else planning to work on this. That said, I think this would be a great addition to the module if someone wants to take on this work.

Since I am asking for it, I'll contribute.
I'm very new here, so I'll need to read up a bit on the subject.

Awesome, thanks! If you need any help, let me know.

Hi Mike,
I've basically copied MSFT_xExchReceiveConnector and changed it to fit New-SendConnector/Set-SendConnector.

It works, but it also fails.
What I mean is it works flawlessly by creating a Send Connector for my environments, but it also throws an error with

Error Message: PowerShell DSC resource MSFT_xExchSendConnector failed to execute Set-TargetResource functionality with error message: Failed to create new Send Connector.

I've attached the psm file, pasting the relevant part below:

        $connector = New-SendConnector @PSBoundParameters

        # Ensure the connector exists, and if so, set us up so we can run Set-SendConnector next
        if ($null -ne $connector)
        {
            # Remove the two props we added
            Remove-FromPSBoundParametersUsingHashtable -PSBoundParametersIn $PSBoundParameters -ParamsToRemove 'Name'

            # Add original props back
            Add-ToPSBoundParametersFromHashtable -PSBoundParametersIn $PSBoundParameters -ParamsToAdd $originalPSBoundParameters
        }
        else
        {
            throw 'Failed to create new Send Connector.'
        }
    }

MSFT_xExchSendConnector.txt

If you can pinpoint me as to what I am doing wrong, or what documentation to read before continuing, I would appreciate it.

Hi @nimsim , can you confirm (probably outside of DSC) that New-SendConnector actually returns a variable? If it doesn't, that's your problem. You'll need to run Get-SendConnector to verify existence.

Hiya @mhendric
You pointed me in the right path. Get/Set-SendConnector did not need $servername in the identity. Removing that solved all the issues I had, and it seems to be working well.

What now? :)

Hi @nimsim . If you're ready to submit for review, the next step would be to create a new pull request with your suggested changes. Here's some instructions to get you started. Let me know if you need any help.

https://github.com/PowerShell/DscResources/blob/master/GettingStartedWithGitHub.md

Hi @nimsim , I'm about to submit a PR for a couple of new resources:
AcceptedDomain,
AddressList,
RemoteDomain.

If you like, I can integrate your code too!
Is the file attached here the latest version?

Hey @SSvilen!

Yes and no, I've since then discovered a new issue that doesn't make sense, and I haven't had time to try to fix it.
MSFT_xExchSendConnector.zip

It might have to do with my script, but I cannot find any references to the parameters Azure is giving errors on.
\"message\": \"VM has reported a failure when processing extension 'dscExtension'. Error message: \\\"DSC Configuration 'InstallAndConfigureExchange' completed with error(s). Following are the first few: Exception calling \\\"Substring\\\" with \\\"2\\\" argument(s): \\\"Length cannot be less than zero.\\r\\nParameter name: length\\\" A parameter cannot be found that matches parameter name 'Name'. The PowerShell DSC resource '[xExchSendConnector]SendConnector' with SourceInfo 'C:\\\\Packages\\\\Plugins\\\\Microsoft.Powershell.DSC\\\\2.77.0.0\\\\DSCWork\\\\ExchangeWorkload.0\\\\ExchangeWorkload.ps1::438::3::xExchSendConnector' threw one or more non-terminating errors while running the Set-TargetResource functionality. These errors are logged to the ETW channel called Microsoft-Windows-DSC/Operational. Refer to this channel for more details.

When I answered mhendric with "It's working!", it really was working, and no changes as far as I know, but can't be sure.

Ok @nimsim , I'll try to debug it on Monday. Do you have also some Pester tests created already?

Ok, I've edited the code a bit - it works now. It's on my repo - in case someone wants to help with creating the pester tests.

Thanks a bunch, sorry for the late reply. Considering I didn't know what a pester test even is, nope :D

I'll try it out soon

No probs. You can start by reading the the docus https://github.com/pester/Pester/wiki and then you can look what I did for xExchAcceptedDomain https://github.com/SSvilen/xExchange/blob/xExchAcceptedDomain/Tests/Unit/MSFT_xExchAcceptedDomain.tests.ps1.
Not that I'm Pester expert, but if you have questions - I'll be glad to help. :)