dsccommunity/ExchangeDsc

xExchReceiveConnector [1.32.0]: Get-ReceiveConnector Not Recognized

Closed this issue · 6 comments

Details of the scenario you tried and the problem that is occurring

DSC fails on xExchReceiveConnector, saying, "The term 'Get-ReceiveConnector' is not recognized as the name of a cmdlet, function, script file, or operable program."

Verbose logs showing the problem

VERBOSE: [CA1-TST-EX01]: LCM:  [ Start  Resource ]  [[xExchReceiveConnector]\SMTP Receive - Relay] 
May 27th 2020 10:11:54Info
VERBOSE: [CA1-TST-EX01]: LCM:  [ Start  Test     ]  [[xExchReceiveConnector]\SMTP Receive - Relay] 
May 27th 2020 10:11:54Info
VERBOSE: [CA1-TST-EX01]:                            [[xExchReceiveConnector]\SMTP Receive - Relay] Entering function  
May 27th 2020 10:11:54Info
'Test-TargetResource'. Notable parameters: Identity = 'CA1-TST-EX01\SMTP Receive - Relay' 
May 27th 2020 10:11:54Info
VERBOSE: [CA1-TST-EX01]:                            [[xExchReceiveConnector]\SMTP Receive - Relay] Entering function  
May 27th 2020 10:11:54Info
'Get-TargetResource'. Notable parameters: Identity = 'CA1-TST-EX01\SMTP Receive - Relay' 
May 27th 2020 10:11:54Info
VERBOSE: [CA1-TST-EX01]:                            [[xExchReceiveConnector]\SMTP Receive - Relay] Reusing existing  
May 27th 2020 10:11:54Info
Remote PowerShell Session to Exchange 
May 27th 2020 10:11:54Info
VERBOSE: [CA1-TST-EX01]:                            [[xExchReceiveConnector]\SMTP Receive - Relay] Importing the  
May 27th 2020 10:11:54Info
xExchange Remote PowerShell Module. 
May 27th 2020 10:11:54Info
VERBOSE: [CA1-TST-EX01]:                            [[xExchReceiveConnector]\SMTP Receive - Relay] Removing the  
May 27th 2020 10:11:54Info
imported "Get-PowerShellVirtualDirectory" function. 
May 27th 2020 10:11:54Info
VERBOSE: [CA1-TST-EX01]:                            [[xExchReceiveConnector]\SMTP Receive - Relay] Loading module from  
May 27th 2020 10:11:54Info
path 'C:\WINDOWS\TEMP\DSCExchangeModule\DSCExchangeModule.psm1'. 
May 27th 2020 10:11:59Info
The term 'Get-ReceiveConnector' is not recognized as the name of a cmdlet, function, script file, or operable program.  
May 27th 2020 10:11:59Info
Check the spelling of the name, or if a path was included, verify that the path is correct and try again. 
May 27th 2020 10:11:59Info
At C:\Octopus\Applications\EXCHANGE-TST\TechnologyInfrastructure.DSC.Global_Exchange\1.0.896019_1\Start-Configuration.p 
May 27th 2020 10:11:59Info
s1:31 char:5 
May 27th 2020 10:11:59Info
+     Start-DscConfiguration -ComputerName $MachineId -Force -Wait -Pat ... 
May 27th 2020 10:11:59Info
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
May 27th 2020 10:11:59Info
    + CategoryInfo          : ObjectNotFound: (Get-ReceiveConnector:) [], CimException 
May 27th 2020 10:11:59Info
    + FullyQualifiedErrorId : CommandNotFoundException 
May 27th 2020 10:11:59Info
 
May 27th 2020 10:11:59Error
The term 'Get-ReceiveConnector' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. 
May 27th 2020 10:11:59Error
Deploy script returned non-zero exit code: 1 
May 27th 2020 10:11:59Error
Running rollback conventions... 

Suggested solution to the issue

We believe this is because 'Get-ReceiveConnector' is not present in DSCExchangeModule.psm1.

The DSC configuration that is used to reproduce the issue (as detailed as possible)

foreach ($RC in $Node.ReceiveConnectorList.Values)
{    
    xExchReceiveConnector $RC.Name
    {
        Identity = $Node.NodeName + $RC.Name
        Ensure = "Present"
        ExtendedRightAllowEntries = $RC.ExtendedRightAllowEntries
        AuthMechanism = $RC.AuthMechanism
        Bindings = $RC.Bindings
        ConnectionInactivityTimeout = $RC.ConnectionInactivityTimeout
        ConnectionTimeout = $RC.ConnectionTimeout
        MaxInboundConnectionPercentagePerSource = $RC.MaxInboundConnectionPercentagePerSource
        MaxInboundConnection = $RC.MaxInboundConnection
        MaxLocalHopCount = $Node.MaxLocalHopCount
        MaxMessageSize = $Node.MaxMessageSize
        MaxAcknowledgementDelay = $RC.MaxAcknowledgementDelay
        PermissionGroups = $RC.PermissionGroups
        RemoteIPRanges = $RC.RemoteIPRanges
        DomainSecureEnabled = $RC.DomainSecureEnabled
        TransportRole = $RC.TransportRole
        Usage = $RC.Usage
        Credential = $AdminCredentials
    }
}

Individual receive connectors, rather than using an array, do the same thing.

Exchange Server edition and version the target node is running

Exchange Server 2019 CU5 Enterprise
Version 15.2 (Build 595.3)

The operating system the target node is running

OsName Microsoft Windows Server 2019 Standard
OsOperatingSystemSKU StandardServerEdition
OsArchitecture 64-bit
WindowsVersion 1809
WindowsBuildLabEx 17763.1.amd64fre.rs5_release.180914-1434
OsLanguage en-US
OsMuiLanguages {en-US}

Version and build of PowerShell the target node is running

PSVersion 5.1.17763.1007
BuildVersion 10.0.17763.1007

Version of the DSC module that was used

xExchange 1.32.0 C:\Program Files\WindowsPowerShell\Modules\xExchange\1.32.0\xExchange.psd1

Thanks for the report @acstyche . @SSvilen , any idea how to fix this?

I'm not able to reproduce the problem. Funny thing is, that it says 'Removing the imported "Get-PowerShellVirtualDirectory" function', then it goes and tries to load the module, but without importing the commands. Example:

VERBOSE: Entering function 'Test-TargetResource'. Notable parameters: Identity = 'SERVER01\AnonymousRelay SERVER01'
VERBOSE: Entering function 'Get-TargetResource'. Notable parameters: Identity = 'SERVER01\AnonymousRelay SERVER01'
VERBOSE: Reusing existing Remote PowerShell Session to Exchange
VERBOSE: Importing the xExchange Remote PowerShell Module.
VERBOSE: Removing the imported "Get-ADPermission" function.
VERBOSE: Removing the imported "Get-ReceiveConnector" function.
VERBOSE: Loading module from path 'C:\Users\ADMINI~1.SVI\AppData\Local\Temp\DSCExchangeModule\DSCExchangeModule.psm1'.
VERBOSE: Importing function 'Get-ADPermission'.
VERBOSE: Importing function 'Get-ReceiveConnector'.

That's from my lab (executing the integration tests).
I've updated also my company test env and did not see any problems.
Does this happen on every server? And on every Start-DSCConfiguration invokation?

Hi @SSvilen,

Thanks for looking into this and confirming you cannot replicate.

Yes, we see the same error on all servers and every invocation.

The 'Removing the imported "Get-PowerShellVirtualDirectory" function' line is because it was loaded in the previous resource. Doesn't each xExchange module load only the commands necessary for the resource, like Get-ReceiveConnector and Get-ADPermission for xExchReceiveConnector? So I think clearing Get-PowerShellVirtualDirectory makes sense.
For us, DSCExchangeModule.psm1 does not contain Get-ReceiveConnector, for some reason.

Turns out, our DevOps team switched our builds from TeamCity to Azure DevOps. So I am going to try bypassing the pipeline and running locally on our test servers. Will let you know how this goes.

@SSvilen, sorry, I think it is, in fact, the switch in build management. I ran the configs successfully outside the pipeline. I was like, "I didn't change anything except module version."
Will keep this open and update when we figure out what is wrong with the pipeline, in case it can help anyone else.

@acstyche Yeah, removing the previously added command is normal, but not adding the new commands is what caught my eye. The missing get-receiveconnector command would explain that.
How that happened - I'm not sure.
The helper module basically exports an Exchange session created beforehand.

Hi,
We successfully built a production DAG on Saturday using this. And after running the config locally in our test environment, we cannot reproduce the issue there.
I have a feeling like this issue will pop up again but think it is down to our pipeline. If this does come back and we find a solution, will update. However, will close this for now.
Thanks a lot for taking a look.