This topic contains 2 replies, has 2 voices, and was last updated by
August 4, 2015 at 1:39 pm #28172ParticipantPoints: 0Rank: Member
I received a message from the PowerShell Gallery script analyzer (PSScriptAnalyzer) that the DSC Configuration scripts I posted contain an error regarding loading xPSDesiredStateConfiguration (error below, same error for all 4 Configuration Scripts).
While I'm not entirely sure, it appears to me that the issue is due to the host running the script analyzer not having the module loaded in it's $env:PSModulePath- I can run all of my own DSC Configuration Scripts on a Windows 10 development VM that has xPSDesiredStateConfiguration so I never encountered this issue in development.
I'd really like to do what I can to resolve this so I am trying to figure out if I can correct this on my end or if I just have no control over what modules the analyzer's host has loaded. Please note that xPSDesiredStateConfiguration is the same module being loaded by xChrome and xFirefox, both currently on the gallery.
The lines that are triggering the script analyzer to return this error are:
Import-DscResource -ModuleName xPSDesiredStateConfiguration
as well as a call to xRemoteFile which is part of xPSDesiredStateConfiguration
ERROR: Invoke-ScriptAnalyzer : Parse error in file
C:\Users\psgadmin\Documents\WindowsPowerShell\Modules\xThunderbird\1.0.6\DSCResources\VH_xThunderbird\VH_xThunderbird.schema.psm1: Unable to load module
'xPSDesiredStateConfiguration': module not found at line 17 column 3.
August 5, 2015 at 5:10 am #28187KeymasterPoints: 1,639Rank: Community Hero
A lot of people run into this, and it seems to be an artifact of the Analyzer. I suspect you're correct in that it's the module not existing locally – Analyzer isn't reaching out to a target machine.
August 13, 2015 at 12:43 pm #28575ParticipantPoints: 0Rank: Member
Don, I heard back from another member of the Config Admin team after I responded to a message from the Script Analyzer-
As it turns out, PSScriptAnalyzer purposely does not load modules (like xPSDesiredStateConfiguration) unless they are explicitly mentioned as one of the RequiredModules in the module manifest. Even if a script explicitly makes a call to Import-Module, the module still needs to be listed in the RequiredModules array in the corresponding module manifest.
For anyone else running into this, the solution is to make sure that the following line exists in all module manifests that need Resources from xPSDesiredStateConfiguration:
RequiredModules = @('xPSDesiredStateConfiguration')
If you are loading more than one external module, add an extra array element for each other module that you need. Note that you don't ever need to include PSDesiredStateConfiguration (non-X) and in fact Publish-Module will return an error if you do try to.
The topic ‘Does PSScriptAnalyzer have access to xPSDesiredStateConfiguration?’ is closed to new replies.