-
Notifications
You must be signed in to change notification settings - Fork 53
Cannot Import PSDscResources #81
Comments
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. |
Let me know if you're still having problems after checking this |
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. |
I also tried the solution listed here: https://msdn.microsoft.com/en-us/powershell/wmf/5.0/limitation_dsc Import-DscResource -ModuleName @{ModuleName='PSDscResources';RequiredVersion='2.8.0.0'} |
I'm not sure which patch fixes this issue, but if possible, I would certainly recommend updating your machine. |
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. |
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. |
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. |
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. |
Okay, I'll look into this further and get back to you as soon as I can. |
@kinwolfqc There must be something else happening in your environment or configuration that is causing this conflict. PsDscResources does not work PsDscResources works 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. Did you install PSDscResources using 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 You could also try just calling 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 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) |
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: 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? |
I use this script from Ashley McGlone to create composite resource manifests and it's basic files quickly |
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) |
@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? |
@kinwolfqc I just figured it out. Somewhere in your code or on your machine, something is calling |
@kwirkykat Holy guacamole! What you describe wasn't the case for us, as we only use Here was the line that was loading the custom resource, and gave the error:
(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:
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 this same bug. I am running the DSC script on a windows docker container:
@kinwolfqc suggestion of changing to one |
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. |
I just hit the same bug with Azure DSC as well. 🍡 |
Fix Get-ModuleScriptResourceNames - Fixes PowerShell#81
I have the same issue as was described in #47 . But I'm not using any insider build
As soon as I install PSDscResources, I am not able to compile any mof anymore(wheter I try to load PSDscResources or not), I always get the error
The server is a Windows 2012 R2
The text was updated successfully, but these errors were encountered: