Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xExchange: Exchange Modules error - all exchange specific resources error: i.e. 'Get-DatabaseAvailabilityGroup' not recognized as the name of a cmdlet, function, script file #464

Open
fruitysfajs opened this issue Apr 1, 2021 · 8 comments
Labels
needs investigation The issue needs to be investigated by the maintainers or/and the community.

Comments

@fruitysfajs
Copy link

fruitysfajs commented Apr 1, 2021

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

Install Exchange 2016 -> works
Configure DAG -> not working
Configure DAGNetwork -> not working
Configure Exchange license -> not working

Verbose logs showing the problem

VERBOSE: [DEV2CHHST-EMH31]:                            [[xExchDatabaseAvailabilityGroup]DAG] Entering function
'Test-TargetResource'. Notable parameters: Name = 'DEV2CHHST-EDG31'
VERBOSE: [DEV2CHHST-EMH31]:                            [[xExchDatabaseAvailabilityGroup]DAG] Importing the xExchange
Remote PowerShell Module.
VERBOSE: [DEV2CHHST-EMH31]:                            [[xExchDatabaseAvailabilityGroup]DAG] Checking if setup is
partially complete
VERBOSE: [DEV2CHHST-EMH31]:                            [[xExchDatabaseAvailabilityGroup]DAG] Checking values at key
'HKLM:\SOFTWARE\Microsoft\ExchangeServer\v15\CafeRole'
VERBOSE: [DEV2CHHST-EMH31]:                            [[xExchDatabaseAvailabilityGroup]DAG] Checking values at key
'HKLM:\SOFTWARE\Microsoft\ExchangeServer\v15\ClientAccessRole'
VERBOSE: [DEV2CHHST-EMH31]:                            [[xExchDatabaseAvailabilityGroup]DAG] Checking values at key
'HKLM:\SOFTWARE\Microsoft\ExchangeServer\v15\FrontendTransportRole'
VERBOSE: [DEV2CHHST-EMH31]:                            [[xExchDatabaseAvailabilityGroup]DAG] Checking values at key
'HKLM:\SOFTWARE\Microsoft\ExchangeServer\v15\HubTransportRole'
VERBOSE: [DEV2CHHST-EMH31]:                            [[xExchDatabaseAvailabilityGroup]DAG] Checking values at key
'HKLM:\SOFTWARE\Microsoft\ExchangeServer\v15\MailboxRole'
VERBOSE: [DEV2CHHST-EMH31]:                            [[xExchDatabaseAvailabilityGroup]DAG] Checking values at key
'HKLM:\SOFTWARE\Microsoft\ExchangeServer\v15\UnifiedMessagingRole'
VERBOSE: [DEV2CHHST-EMH31]:                            [[xExchDatabaseAvailabilityGroup]DAG] Exchange is present and
setup is detected as being fully complete.
VERBOSE: [DEV2CHHST-EMH31]:                            [[xExchDatabaseAvailabilityGroup]DAG] Creating new Remote
PowerShell session to Exchange
VERBOSE: [DEV2CHHST-EMH31]:                            [[xExchDatabaseAvailabilityGroup]DAG] Perform operation
'Enumerate CimInstances' with following parameters, ''namespaceName' = root\cimv2,'className' = Win32_ComputerSystem'.
VERBOSE: [DEV2CHHST-EMH31]:                            [[xExchDatabaseAvailabilityGroup]DAG] Operation 'Enumerate
CimInstances' complete.
VERBOSE: [DEV2CHHST-EMH31]:                            [[xExchDatabaseAvailabilityGroup]DAG] Connecting to
dev2chhst-emh31.dev2.swisscom-mcc.local.
VERBOSE: [DEV2CHHST-EMH31]:                            [[xExchDatabaseAvailabilityGroup]DAG] Loading module from path
'C:\Windows\TEMP\DSCExchangeModule\DSCExchangeModule.psm1'.
VERBOSE: [DEV2CHHST-EMH31]:                            [[xExchDatabaseAvailabilityGroup]DAG] No need to remove
parameters
The term 'Get-DatabaseAvailabilityGroup' 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.
    + CategoryInfo          : ObjectNotFound: (Get-DatabaseAvailabilityGroup:) [], CimException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

VERBOSE: [DEV2CHHST-EMH31]:                            [[xExchDatabaseAvailabilityGroup]DAG] Unable to retrieve
Database Availability Group settings
VERBOSE: [DEV2CHHST-EMH31]: LCM:  [ End    Test     ]  [[xExchDatabaseAvailabilityGroup]DAG]  in 7.5310 seconds.
The PowerShell DSC resource '[xExchDatabaseAvailabilityGroup]DAG' with SourceInfo 'C:\DSC\psf_TestConfig\ExchangeAutom
tion\applicationConfiguration_EX_WS_New.ps1::457::17::xExchDatabaseAvailabilityGroup' threw one or more
non-terminating errors while running the Test-TargetResource functionality. These errors are logged to the ETW channel
called Microsoft-Windows-DSC/Operational. Refer to this channel for more details.
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : NonTerminatingErrorFromProvider
    + PSComputerName        : localhost

VERBOSE: [DEV2CHHST-EMH31]: LCM:  [ Start  Resource ]  [[xExchClientAccessServer]CAS]
VERBOSE: [DEV2CHHST-EMH31]: LCM:  [ Start  Test     ]  [[xExchClientAccessServer]CAS]
VERBOSE: [DEV2CHHST-EMH31]:                            [[xExchClientAccessServer]CAS] Entering function
'Test-TargetResource'. Notable parameters: Identity = 'dev2chhst-emh31'
VERBOSE: [DEV2CHHST-EMH31]:                            [[xExchClientAccessServer]CAS] Reusing existing Remote
PowerShell Session to Exchange
VERBOSE: [DEV2CHHST-EMH31]:                            [[xExchClientAccessServer]CAS] Importing the xExchange Remote
PowerShell Module.
VERBOSE: [DEV2CHHST-EMH31]:                            [[xExchClientAccessServer]CAS] Loading module from path
'C:\Windows\TEMP\DSCExchangeModule\DSCExchangeModule.psm1'.
The term 'Get-ClientAccessService' 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.
    + CategoryInfo          : ObjectNotFound: (Get-ClientAccessService:) [], CimException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

Unable to retrieve Client Access Server settings for server
    + CategoryInfo          : NotSpecified: (:) [], CimException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Test-TargetResource
    + PSComputerName        : localhost

VERBOSE: [DEV2CHHST-EMH31]: LCM:  [ End    Test     ]  [[xExchClientAccessServer]CAS]  in 0.0780 seconds.
The PowerShell DSC resource '[xExchClientAccessServer]CAS' with SourceInfo
'C:\DSC\psf_TestConfig\ExchangeAutomation\applicationConfiguration_EX_WS_New.ps1::562::13::xExchClientAccessServer'
threw one or more non-terminating errors while running the Test-TargetResource functionality. These errors are logged
to the ETW channel called Microsoft-Windows-DSC/Operational. Refer to this channel for more details.
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : NonTerminatingErrorFromProvider
    + PSComputerName        : localhost

VERBOSE: [DEV2CHHST-EMH31]: LCM:  [ Start  Resource ]  [[xExchExchangeServer]EXServerLicense]
VERBOSE: [DEV2CHHST-EMH31]: LCM:  [ Start  Test     ]  [[xExchExchangeServer]EXServerLicense]
VERBOSE: [DEV2CHHST-EMH31]:                            [[xExchExchangeServer]EXServerLicense] Entering function
'Test-TargetResource'. Notable parameters: Identity = 'dev2chhst-emh31'
VERBOSE: [DEV2CHHST-EMH31]:                            [[xExchExchangeServer]EXServerLicense] Reusing existing Remote
PowerShell Session to Exchange
VERBOSE: [DEV2CHHST-EMH31]:                            [[xExchExchangeServer]EXServerLicense] Importing the xExchange
Remote PowerShell Module.
VERBOSE: [DEV2CHHST-EMH31]:                            [[xExchExchangeServer]EXServerLicense] Loading module from path
'C:\Windows\TEMP\DSCExchangeModule\DSCExchangeModule.psm1'.
The term 'Get-ExchangeServer' 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.
    + CategoryInfo          : ObjectNotFound: (Get-ExchangeServer:) [], CimException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

Suggested solution to the issue

Unknown.
I tried to run the start-dscconfiguration directly from a Exchange Powershell Session and still get the same errors

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

# Create the DAG
                xExchDatabaseAvailabilityGroup DAG
                {
                    Name                                 = $DAGName
                    Credential                           = $ExchangeInstallCredential
                    DatacenterActivationMode             = $DAGActivationMode
                    AutoDagTotalNumberOfServers          = 4
                    
                    ManualDagNetworkConfiguration        = $DAGManualDAGNetConfig
                    ReplayLagManagerEnabled              = $DAGReplayLagManagerEnabled
                    SkipDagValidation                    = $true
                    WitnessDirectory                     = $DAGWitNessDirectory
                    WitnessServer                        = $DAGWitnessServer
                    Filesystem                           = $DAGFileSystem
                    NetworkCompression                   = $DAGNetcompression
                    NetworkEncryption                    = $DAGNetencryption
                    #SkipDagValidation                    = $DAGSkipValidation
                    DatabaseAvailabilityGroupIPAddresses = $DAGIPAddresses
                    DependsOn                            = '[Script]RebootAfterExchangeInstall'
                }
                $FinalStatusDependencies += "[xExchDatabaseAvailabilityGroup]DAG"
            # This section licenses the server
            xExchExchangeServer EXServerLicense
            {
                Identity            = $node.computername
                Credential          = $ExchangeInstallCredential
                ProductKey          = '7WJV6-H9RMH-F4267-3R2KG-F6PBY'
                AllowServiceRestart = $true
                DependsOn = '[Script]RebootAfterExchangeInstall'
            }
            $FinalStatusDependencies += "[xExchExchangeServer]EXServerLicense"

Exchange Server edition and version the target node is running

Exchange 2016 CU19

The operating system the target node is running

OsName               : Microsoft Windows Server 2012 R2 Standard
OsOperatingSystemSKU : StandardServerEdition
OsArchitecture       : 64-bit
WindowsBuildLabEx    : 9600.19067.amd64fre.winblue_ltsb_escrow.180619-2033
OsLanguage           : en-US
OsMuiLanguages       : {en-US}

Version and build of PowerShell the target node is running

Name                           Value
----                           -----
PSVersion                      5.1.14409.1012
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14409.1012
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Version of the DSC module that was used

Name      Version Path
----      ------- ----
xExchange 1.32.0  C:\Program Files\WindowsPowerShell\Modules\xExchange\1.32.0\xExchange.psd1
@johlju
Copy link
Member

johlju commented Oct 3, 2021

It seems the Exchange PowerShell module is not found by the resources. Was it installed. Was there a reboot between Exchange install and trying to configure Exchange server? 🤔

@johlju johlju added the needs more information The issue needs more information from the author or the community. label Oct 3, 2021
@fruitysfajs
Copy link
Author

fruitysfajs commented Oct 14, 2021

Hi, thanks for the feedback. Yes the Exchange Management Shell is installed, it is also possible to run all exchange commands manually when loading the exchange PS Module. But DSC does not seem to recognize it at all. It seems very strange.
Example: Load exchange module in Powershell console, run any Exchange commands -> no issue. Same Powershell session and running start-dscconfiguration and for every xExchange resource I get the errors as you see above that the cmdlet cannot be found.

Yes after the Exchange setup there is always a reboot before following up with the configuration part.

Do you maybe have any ideas?

cheers, Peter

@johlju
Copy link
Member

johlju commented Oct 14, 2021

The commando Start-DscConfiguration Is rum in the session you start it in, but the configuration is not. The command tells the LCM to run the configuration. The LCM runs as SYSTEM (unless proving a different user in the configuration) in its own PowerShell session.

@tron2k
Copy link
Contributor

tron2k commented Oct 26, 2021

@fruitysfajs
The DSC Module xExchange creates a module for the Exchange remote session under c:\windows\Temp\DSCExchangeModule. I suspect that in the module the function Get-DatabaseAvailabilityGroup is not present in the DSCExchangeModule.psm1 module file. You can simply rename the folder DSCExchangeModule and wait few minutes. xExchange will recreate this module. Then all functions should be available.

I had the problem a few days ago with the Get-ClientAccessServer function/cnmdlet and recreating the DSCExchangeModule solved the problem.

@johlju
Copy link
Member

johlju commented Oct 31, 2021

This sounds like an intermittent problem.

@Ilativ is the problem that it creates the folder DSCExchangeModule in the temporary folder but not the module file? Would be great to know what differ from the first run (where renaming the folder) to the next run where it works.

@johlju johlju added needs investigation The issue needs to be investigated by the maintainers or/and the community. and removed needs more information The issue needs more information from the author or the community. labels Oct 31, 2021
@tron2k
Copy link
Contributor

tron2k commented Nov 5, 2021

@johlju the module file was created but in my case the function Get-ClientAccessServer was not present.
These are the two modules files DSCExchangeModule File.zip

@poshable
Copy link

So I know this is a really old issue, but I've been seeing regular cases where c:\windows\Temp\DSCExchangeModule is empty and xExchange resources are failing when they need to run Exchange cmdlets to test/set resources. When the folder is empty, the module doesn't seem to get recreated, but if I delete the folder entirely, the module is recreated and everything is good again. Very strange, and not sure how/why the module is ever removed in the first place once it's been created.

@tron2k
Copy link
Contributor

tron2k commented Feb 16, 2023

@poshable
I do not know what is happening in your environment but you can try the following:
In C:\Program Files\WindowsPowerShell\Modules\cExchange\source\Modules\xExchangeHelper\xExchangeHelper.psm1 change Line 96 from
$exportedModule = Test-Path -Path $script:DSCExchangeModulePath
to
$exportedModule = Test-Path -Path $(Join-Path -Path $script:DSCExchangeModulePath -ChildPath "$script:DSCExchangeModuleName.psm1")

That should solve your problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs investigation The issue needs to be investigated by the maintainers or/and the community.
Projects
None yet
Development

No branches or pull requests

4 participants