Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composite resources modules #18

Closed
bartvermeersch opened this issue Jan 21, 2025 · 4 comments
Closed

Composite resources modules #18

bartvermeersch opened this issue Jan 21, 2025 · 4 comments

Comments

@bartvermeersch
Copy link

Hello Yorick, thank you for the wonderful resources.

I'm still struggling with the composite resources, I use to create them manually (using the previous white paper).

What is the difference between the modules M365DSC.CRG and M365DSC.CompositeResources?

When trying to install the latter on an empty brand new windows sandbox, as specified in the white paper:

To export the example data file to a location of your choice, take the following steps:
▪ Install the M365DSC.CompositeResources module
▪ Run the command New-M365DSCExampleDataFile -OutputPath

I receive the error:

PackageManagement\Install-Package : The following commands are already available on this system:'Publish-DscConfiguration'. This module 'DscBuildHelpers' may
override the existing commands. If you still want to install this module 'DscBuildHelpers', use -AllowClobber parameter.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1809 char:21
+ ...          $null = PackageManagement\Install-Package @PSBoundParameters
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
    + FullyQualifiedErrorId : CommandAlreadyAvailable,Validate-ModuleCommandAlreadyAvailable,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

After installing it with Allowclobber, I'm unable to run New-M365DSCExampleDataFile

New-M365DSCExampleDataFile : The 'New-M365DSCExampleDataFile' command was found in the module 'M365DSC.CompositeResources', but the module could not be loaded. For
more information, run 'Import-Module M365DSC.CompositeResources'.
At line:1 char:1
+ New-M365DSCExampleDataFile -OutputPath "c:\temp"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (New-M365DSCExampleDataFile:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CouldNotAutoloadMatchingModule
@bartvermeersch
Copy link
Author

Ok, I managed to get it working after all (with the allowclobber parameter)

If you could shed a light on the remaining question:
What is the difference between the modules M365DSC.CRG and M365DSC.CompositeResources?

And would it be possible to use the generated psd1 file (M365ConfigurationDataExample.psd1) in VS code to autocomplete?

@ykuijs
Copy link
Owner

ykuijs commented Jan 22, 2025

M365DSC.CompositeResources vs M365DSC.CRG

The module M365DSC.CRG contains the code that I am using to generate the M365DSC.CompositeResources module. Each night a scheduled pipeline runs in the M365DSC.CompositeResources repository that checks if a new version of Microsoft365DSC has been released. If so, it start the generation of the M365DSC.CompositeResources by downloading the M365DSC.CRG module and then executing the code in that module. That code uses the new version of Microsoft365DSC to generate all composite resources for M365DSC.CompositeResources, using the schema of all DSC resources in M365DSC.

So as an user of this solution, there is no need to download or use the M365DSC.CRG module. That is why I haven't mentioned it anywhere in the whitepaper, since it will only add confusion.

Using M365ConfigurationDataExample.psd1 in VS code

This is an interesting idea. I am not sure if that is possible, haven't seen such a possibility before. Really interested if that would be possible. If anyone knows how to do this, please share!

One challenge I can come up with here is that there is no official way to describe a schema for a PSD1 file, unlike XML for example. So the schema we have created here, is something custom that isn't following any standard (since there is non).

@ykuijs
Copy link
Owner

ykuijs commented Jan 22, 2025

Just created a feature suggestion here: PowerShell/vscode-powershell#5131

Please reply and vote for it!

@ykuijs
Copy link
Owner

ykuijs commented Jan 29, 2025

Based on the reply in the linked issue, this suggestion is not getting implemented by the vscode extension because of the lack of a formal schema validation availability for psd1 files.

Closing this issue here.

@ykuijs ykuijs closed this as completed Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants