Author Posts

November 23, 2017 at 6:39 am

I copied a DSC Resource cChoco to C:\Program Files\WindowsPowerShell\Modules but still when i do get-dscresource it doesn`t show this cChoco module.
When i copied the resource to C:\Windows\System32\WindowsPowerShell\v1.0\Modules the Get-Dscresource command stopped working it said the command cannot be found.

Any idea to resolve this without applying any patch or uppdate.
Currently i am on PS version 4

November 28, 2017 at 6:19 pm

Definitely don't copy stuff into System32. That's Microsoft's playground not ours :).

Check the PSModulePath environment variable and ensure your Program Files path is listed. Also ensure that the cChoco module is correctly laid out – it would normally have a DscResources subfolder, it needs the correct .psd1 manifest files, a schema MOF, and so on. All of those things need to be correct for PowerShell to "see" it.

You haven't provided any information about the environment (versions, etc) or commands you're running, but I'm guessing that (A) the module isn't properly structured and (B) your PSModulePath isn't complete.

November 29, 2017 at 7:34 am

I ran install-module cchoco on my source that is on PS version 5.0 and then i copied the cchoco module from my source to my client which is on PS version 4.0 but i can`t see it in get-dscresource

Do you still think it`s structure issue as the module is working fine on my source

November 29, 2017 at 3:00 pm

The structure should be fine wither way. Either (a) PSModulePath on your v4 machine doesn't include that path or (b) the module itself isn't v4 compatible.

November 30, 2017 at 7:12 am

Here is my PSModulePath on v4 machine
PS C:\Windows\system32> $env:PSModulePath
C:\Users\salttest\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\
WindowsPowerShell\v1.0\Modules\;C:\Program Files (x86)\AWS Tools\PowerShell\

Once i apply packagemanagement patch n use install-module the resource is working fine so that means that it`s compatible na?

November 30, 2017 at 2:31 pm

It doesn't mean it's compatible, no. Install-Module doesn't check for compatibility of the code, it just copies the files. The PSModulePath looks correct, though.

December 1, 2017 at 2:45 am

One thing i cam across the other day taking a module from a machine on v5 to v4 was the module having a version number in the path broke the module eg:

C:\Program Files\WindowsPowerShell\Modules\PowerShellCookbook\1.3.6

But if i move the module contents up one level to

C:\Program Files\WindowsPowerShell\Modules\PowerShellCookbook

It is then picked up.

December 13, 2017 at 11:06 am

Thanks @alex You are a life saver