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

MSFT_xCluster - Common helper module not importing properly #214

Closed
wsmelton opened this issue Dec 18, 2019 · 2 comments · Fixed by #215
Closed

MSFT_xCluster - Common helper module not importing properly #214

wsmelton opened this issue Dec 18, 2019 · 2 comments · Fixed by #215
Labels
bug The issue is a bug.

Comments

@wsmelton
Copy link

Changes in folder layout and import process for the helper module no longer works. Testing a configuration that is using xCluster resource ends with this failure:

writeErrorStream      : True
PSMessageDetails      :
OriginInfo            : localhost
Exception             : Microsoft.Management.Infrastructure.CimException: Importing module MSFT_xCluster failed with
                        error - The term 'Get-LocalizedData' 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.
                           at Microsoft.Management.Infrastructure.Internal.Operations.CimAsyncObserverProxyBase`1.Proce
                        ssNativeCallback(OperationCallbackProcessingContext callbackProcessingContext, T currentItem,
                        Boolean moreResults, MiResult operationResult, String errorMessage, InstanceHandle
                        errorDetailsHandle)
TargetObject          : root/Microsoft/Windows/DesiredStateConfiguration:MSFT_DSCLocalConfigurationManager
CategoryInfo          : InvalidOperation: (root/Microsoft/...gurationManager:String) [], CimException
FullyQualifiedErrorId : ImportModuleFailed
ErrorDetails          :
InvocationInfo        :
ScriptStackTrace      :
PipelineIterationInfo : {}

Seems to be tied down to the import of the CommonResourceHelper is not happening properly. This is on version 1.14.0 of the xFailoverCluster module.

@wsmelton
Copy link
Author

Manifest file needs to be updated to include the root module and export of functions so PS properly imports the psm1 file. Local testing and the contents of the CommonResourceHelper.psd1 allows everything to work again:

@{
    # Version number of this module.
    ModuleVersion = '1.0'
    # ID used to uniquely identify this module
    GUID = 'b8e5084a-07a8-4135-8a26-00614e56ba71'

    RootModule = 'CommonResourceHelper.psm1'

    # Author of this module
    Author = 'DSC Community'

    # Company or vendor of this module
    CompanyName = 'DSC Community'

    # Copyright statement for this module
    Copyright = 'Copyright the DSC Community contributors. All rights reserved.'

    # Description of the functionality provided by this module
    Description = 'Functions used by the DSC resources in SqlServerDsc.'

    # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
    FunctionsToExport = @('New-InvalidArgumentException',
    'New-InvalidOperationException',
    'New-ObjectNotFoundException',
    'New-InvalidResultException',
    'Get-LocalizedData')

    # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
    CmdletsToExport = @()

    # Variables to export from this module
    VariablesToExport = @()

    # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
    AliasesToExport = @()

    # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
    PrivateData = @{
        PSData = @{
        } # End of PSData hashtable
     } # End of PrivateData hashtable
}

@wsmelton
Copy link
Author

wsmelton commented Dec 18, 2019

Additional item, the MSFT_xCluster.psm1 file will need to directly import the psd1 file:

Import-Module -Name "$script:resourceHelperModulePath\CommonResourceHelper.psd1" -Verbose

Just using the folder path does not work.

@johlju johlju added bug The issue is a bug. in progress The issue is being actively worked on by someone. labels Dec 18, 2019
johlju added a commit that referenced this issue Dec 18, 2019
- CommonResourceHelper
  - Fix unit tests to load the helper modules using module manifest.
  - Fix to correctly export the functions in the helper module
    ([issue #214](#214)).
  - Fix typo in module manifest.
@johlju johlju removed the in progress The issue is being actively worked on by someone. label Jun 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants