GithubHelp home page GithubHelp logo

Comments (20)

SylvainMartel avatar SylvainMartel commented on August 18, 2024 3

@kwirkykat Holy guacamole! What you describe wasn't the case for us, as we only use Import-DscResource -Module PSDscResources -ModuleVersion 2.8.0.0 , but it did give me a hint.

Here was the line that was loading the custom resource, and gave the error:

Import-DscResource -Module xActiveDirectory, DSQCompositeResources
Import-DscResource -Module PSDscResources -ModuleVersion 2.8.0.0

(AFAIK loading more than one module on one line was always allowed as it never caused us any problem until we tried also loading PsDscResources)

Here is the simple fix making it all work:

Import-DscResource -Module xActiveDirectory
Import-DscResource -Module DSQCompositeResources
Import-DscResource -Module PSDscResources -ModuleVersion 2.8.0.0

I guess DSC does something funny to the second or third module it tries to load when we use simple commas instead of repeating the whole "Import-DscResource" line?

Thanks a million for your time. We can now use the newer PSDscResources

from psdscresources.

SylvainMartel avatar SylvainMartel commented on August 18, 2024 1

It might be easier for Windows 2016 since it looks like there are only cumulative updates for that OS, so the security team can't get picky about what to install. I'll ask for the latest to be installed on my test machine and report back.

from psdscresources.

mbreakey3 avatar mbreakey3 commented on August 18, 2024

Did you make sure you have all the latest windows updates? This looks like a very similar case/environment as issue #43, and installing all of the latest patches fixed his issue.

from psdscresources.

mbreakey3 avatar mbreakey3 commented on August 18, 2024

Let me know if you're still having problems after checking this

from psdscresources.

SylvainMartel avatar SylvainMartel commented on August 18, 2024

Perusing the issue, I see that the patch that might solve this was never identified. Since I am on a corporate network, many patches are not deployed if the security team thinks they are not warranted, but if the right patch is identified, I can ask for it to be installed. Anyone managed to identify the patch required? A quick search on google didn't give any clue either.

As extra information, I have also tried installing PSDscResources on a test Windows 2016 server(using Install-Module PSDscResources) , and as soon as it's there, the problem appear too, even if I do not try to load PSDscResources.

from psdscresources.

SylvainMartel avatar SylvainMartel commented on August 18, 2024

I also tried the solution listed here: https://msdn.microsoft.com/en-us/powershell/wmf/5.0/limitation_dsc
but the result stays the same.

Import-DscResource -ModuleName @{ModuleName='PSDscResources';RequiredVersion='2.8.0.0'}

from psdscresources.

mbreakey3 avatar mbreakey3 commented on August 18, 2024

I'm not sure which patch fixes this issue, but if possible, I would certainly recommend updating your machine.
As for the 2016 machine, what is the PowerShell version installed on that machine?

from psdscresources.

SylvainMartel avatar SylvainMartel commented on August 18, 2024

Windows 2016 PS version. Strange, it looks older than the WMF 5.1 we downloaded for Win2012R2. But afaik, there are no WMF 5.1 download available for Win2016 so I guess this is the most recent version for that OS.

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

As for updating the 2012R2 server: I'd love to. But in our corporate environment, I have no control over that unless I open a problem in the internal ticketing. But if I can't give them a hint of what kb to look at, I already know it will stay open forever. I'll try to search some more to see if I find some related KB.

from psdscresources.

mbreakey3 avatar mbreakey3 commented on August 18, 2024

Do you know if there's any Windows updates for the 2016 machine? I apologize for the inconvenience this is causing. We had to make some significant changes to our system in order for this module to work since the resource names are the same as in PSDesiredStateConfiguration, so we depend on the machines have the most recent updates.

from psdscresources.

SylvainMartel avatar SylvainMartel commented on August 18, 2024

We installed the latest cumulative update on Windows 2016(KB4025334), rebooted, and sadly the problem is still there. The powershell version changed to:

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

But still, as soon as we install PSDscResources, we cannot compile mof's anymore, even if we do not try to load PSDscResources inside the configuration.

from psdscresources.

mbreakey3 avatar mbreakey3 commented on August 18, 2024

Okay, I'll look into this further and get back to you as soon as I can.

from psdscresources.

kwirkykat avatar kwirkykat commented on August 18, 2024

@kinwolfqc There must be something else happening in your environment or configuration that is causing this conflict.
I have confirmed that PSDscResources works/does not work in these WMF versions:

PsDscResources does not work
5.1.15063.296 -- WMF 5.1 in Windows 10 Creators Update prior to 6/16/17
5.1.15063.0 -- WMF 5.1 in Windows 10 Creators Update
5.1.15055.0 -- WMF 5.1 in a past Windows Insider Update
5.1.14394.1000 -- WMF 5.1 preview version
5.0 or below

PsDscResources works
5.1.14393.953 -- version out on Windows 10/Windows Server 2016 BEFORE Creators update
5.1.14409.1005 -- downloadable WMF 5.1
5.1.15063.413 -- current version out on Windows 10 as of 6/16/17

I've tested with WMF 5.1.14409.1005 which is what you have on your Windows 2012 R2 machine and it works fine for me there.
I can't speak as confidently for the more recent versions of 5.1.14393, but I know 5.1.14393.953 worked, and as far as I know none of the problems with DSC in Windows 10 ever reached any version of Windows Server.

Did you install PSDscResources using Install-Module?

A possible (but it sounds like not probable) problem that could be occurring is that other module(s) is/are implicitly trying to import PSDesiredStateConfiguration and PSDscResources at the same time as dependencies. You can check the RequiredModules field in the module manifest (.psd1) file of any other modules you are importing in your configuration(s) to see if they are importing either of those modules as dependencies.

Could you share your configuration or maybe just the part of it where you call Import-DscResource?

You could also try just calling Import-Module PSDesiredStateConfiguration and Import-Module PSDscResources to see if the modules themselves will even import outside a configuration (they should if everything is working correctly).

It could also be some bizarre problem with your PSModulePath. Though I'm not really sure how.

Have you tried a different, very basic configuration like configuration myconfig { Import-DscResource -ModuleName PSDesiredStateConfiguration } on the same machine?

The specific function you are having a problem with is actually in PowerShell itself, not in DSC, so you can see their most recent code for the function throwing the error in their open source code here: https://github.com/PowerShell/PowerShell/blob/ffd39b2853b68419eb0fd5e34a89b755c98b8022/src/System.Management.Automation/DscSupport/CimDSCParser.cs#L2180 (But keep in mind that code is for PowerShell Core and not the exact version of PowerShell you are using)

from psdscresources.

SylvainMartel avatar SylvainMartel commented on August 18, 2024

I did what you proposed, starting with a new basic configuration, and I added stuff in it until it broke. Doing so, I was able to find the problem, but not the solution:
We use composite resources to keep the main script manageable, and to be able to reuse the code we put in the composite resource in other configurations. As soon as we import a composite resource, we get the error message. But I looked into the manifests of the composite resource and nowhere does it load, or ask for, PSDesiredStateConfiguration, or any other modules for that matter.

So I did another test, I created a completely new, and empty, composite resource and as soon as I tried to import it(while PSDscResources 2.8.0.0 was present) I got the dreaded

ImportClassResourcesFromModule : Exception calling "ImportClassResourcesFromModule" with "3" argument(s): "Resource name 'WindowsPackageCab' is already being used by another Resource or
Configuration."
At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psm1:2109 char:35
+ ... rcesFound = ImportClassResourcesFromModule -Module $mod -Resources $r ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [ImportClassResourcesFromModule], MethodInvocationException
    + FullyQualifiedErrorId : PSInvalidOperationException,ImportClassResourcesFromModule

So could it be a bug related to the way composite resources are called/used?

from psdscresources.

SylvainMartel avatar SylvainMartel commented on August 18, 2024

I use this script from Ashley McGlone to create composite resource manifests and it's basic files quickly
https://gallery.technet.microsoft.com/Helper-Function-to-Create-bf248c68

from psdscresources.

SylvainMartel avatar SylvainMartel commented on August 18, 2024

Any update on this? Right now it seems we are offered two choices: Either use Composite Resource and not be able to update the original PSDscResource, or be able to update PSDscResource and forego using Composite Resources(which makes our configurations pretty much unmanageable so much they get big)

from psdscresources.

kwirkykat avatar kwirkykat commented on August 18, 2024

@kinwolfqc I tried out using PSDscResources along with some custom composite configurations and it all works fine for me. PSDscResources itself has several composite resources as well (all the *Set resources). So it doesn't seem to be a problem within PSDscResources.

What about in the .schema.psm1 files of the composite resources? They don't import any modules or DSC resources there either?

from psdscresources.

kwirkykat avatar kwirkykat commented on August 18, 2024

@kinwolfqc I just figured it out. Somewhere in your code or on your machine, something is calling Import-Module PSDscResources instead of Import-DscResource -Module PSDscResources. The first one results in the error you gave. The second one works fine. You shouldn't ever have to directly import PSDscResources with Import-Module. In all your configurations and composite resources you can just call Import-DscResource -Module PSDscResources.

from psdscresources.

dazinator avatar dazinator commented on August 18, 2024

I just hit this same bug. I am running the DSC script on a windows docker container:

FROM microsoft/mssql-server-windows-developer:2017-latest

@kinwolfqc suggestion of changing to one Import-DscResource per line has fixed it..
How come this is necessary though? Won't it continue to catch others out?

from psdscresources.

rdtechie avatar rdtechie commented on August 18, 2024

Just encountered the same bug. When trying to import PSDesiredStatedConfiguration and some other DSC resources with a oneliner, I receive a error message like the one in the start of this issue. When changing to import one at a time, I don't receive the error and import succeeds.

from psdscresources.

aut0pil0t avatar aut0pil0t commented on August 18, 2024

@kwirkykat Holy guacamole! What you describe wasn't the case for us, as we only use Import-DscResource -Module PSDscResources -ModuleVersion 2.8.0.0 , but it did give me a hint.

Here was the line that was loading the custom resource, and gave the error:

Import-DscResource -Module xActiveDirectory, DSQCompositeResources
Import-DscResource -Module PSDscResources -ModuleVersion 2.8.0.0

(AFAIK loading more than one module on one line was always allowed as it never caused us any problem until we tried also loading PsDscResources)

Here is the simple fix making it all work:

Import-DscResource -Module xActiveDirectory
Import-DscResource -Module DSQCompositeResources
Import-DscResource -Module PSDscResources -ModuleVersion 2.8.0.0

I guess DSC does something funny to the second or third module it tries to load when we use simple commas instead of repeating the whole "Import-DscResource" line?

Thanks a million for your time. We can now use the newer PSDscResources

I just hit the same bug with Azure DSC as well. 🍡

from psdscresources.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.