Page 1 of 1

Module Not Loading in Studio - ConfigurationManager

Posted: Fri Oct 18, 2019 6:32 am
by ccs_devops
Product, version and build: PowerShell Studio 2019 /
32 or 64 bit version of product: 64
Operating system: Windows Server 2016 Std
32 or 64 bit OS: 64

Trying to load ConfigurationManager module into PowerShell Studio. I also have PowerShell Studio 2016 on a separate system and it works fine, loads the module, available in studio. When I attempt this in 2019, I get an error stating ResourceUnavailable. Added the path to the $env:PSModulePath (c:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin)
all users / hosts.
I successfully added the module to the cache via the editor and rebuilt the cache, without issue.

I have a simple script for testing this, test_load_modules.ps1;

Code: Select all

#Requires -Module ConfigurationManager
Get-Command -Module ConfigurationManager -Verb Get
Running the script through studio produces the following error:

Code: Select all

ERROR: C:\scripts\working\test_load_modules.ps1 : The script 'test_load_modules.ps1' cannot be run because the following modules that are specified by the
ERROR: "#requires" statements of the script are missing: ConfigurationManager.
line (1, 1): ERROR: At Line: 1 char: 1
ERROR: + C:\scripts\working\test_load_modules.ps1
ERROR: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR:     + CategoryInfo          : ResourceUnavailable: (test_load_modules.ps1:String) [], ScriptRequiresException
ERROR:     + FullyQualifiedErrorId : ScriptRequiresMissingModules
pss2019_module_loading_error.jpg (113.07 KiB) Viewed 2312 times
The server is up to date, PowerShell Studio is up to date and as mentioned, I have PowerShell studio 2016 on another system and it loads the module without issue, the systems were essentially setup the same.

Any suggestions would be appreciated, thanks.

Re: Module Not Loading in Studio - ConfigurationManager

Posted: Fri Oct 18, 2019 7:29 am
by brittneyr
It appears that it is not finding your module. If you use import-module with the path to the module, does it still fail?

Also, are you able to run your test script from the ISE?

Re: Module Not Loading in Studio - ConfigurationManager

Posted: Fri Oct 18, 2019 8:00 am
by ccs_devops
Yes the module loads as expected in the ISE:

ise_loading_module.JPG (51.36 KiB) Viewed 2298 times

Actually I am a bit embarrassed I didn't try this before posting but, it will load in Studio if the path to the module is explicitly defined:

pss2019_loading_module.JPG (52.24 KiB) Viewed 2298 times

Honestly, this works for my needs but, it still doesn't explain why this module cannot be referenced by name only, in Studio 2019.

I appreciate the response.

Re: Module Not Loading in Studio - ConfigurationManager

Posted: Mon Oct 28, 2019 5:42 pm
by Alexander Riedel
If you look at your ISE screenshot, you are runing it as administrator, elevated. As per your PowerShell Studio screenshot, you do not run the script elevated there.
So you have two different environments, access rights and potentially different PSModulePath settings.