Open NemoDima opened 4 years ago
Hi @NemoDima - sorry about the delay in getting back to you.
This is because you're importing both PSDesiredStateConfiguration and PSDscResources into the same configuration.
PSDscResources is a complete replacement for PSDesiredStateConfiguration. Just import the newer PSDscResources and remove the Import-DscResource PSDesiredStateConfiguration
.
Is there any way to suppress, then, the following Warning?
WARNING: The configuration 'xxx' is loading one or more built-in resources without explicitly importing associated modules. Add Import-DscResource -ModuleName 'PSDesiredStateConfiguration' to your configuration to avoid this message.
Can you share your configuration @richardgavel ?
Hi @NemoDima - sorry about the delay in getting back to you.
This is because you're importing both PSDesiredStateConfiguration and PSDscResources into the same configuration.
PSDscResources is a complete replacement for PSDesiredStateConfiguration. Just import the newer PSDscResources and remove the
Import-DscResource PSDesiredStateConfiguration
.
No - it is NOT a replacement. The PSDscResources is supposed to overwrite resources in the built-in PSDesiredStateConfiguration (according to https://github.com/PowerShell/PSDscResources) - but it does not export any commands or cmdlets. So whenever you use Start-DscConfiguration or Publish-DscConfiguration, the PSDesiredStateConfiguration module loads.
Can you share your configuration @richardgavel ?
I was able to reproduce the problem by creating a configuration with a File resource.
You can see the it by opening the following file with PowerShell ISE and clicking the Run Script button in the toolbar.
PowerShell will say:
At C:\Users\zchoy\Desktop\Example Configuration.ps1:5 char:5
+ Import-DscResource -ModuleName 'PSDscResources'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Resource name 'Archive' is already being used by another Resource or Configuration.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : DuplicateKeywordDefinition
Then, uncomment the first import (PSDesiredStateConfiguration) and press Run Script again.
Now, it will run successfully but PowerShell will show a different message.
WARNING: The configuration 'EnvironmentVariable_Path' is loading one or more built-in resources without explicitly importing associated modules. Add Import-DscResource –ModuleName 'PSDesiredStateConfiguration' to your configuration to avoid this message.
I've attached the file inside a ZIP file.
When I tried to share the PS1 file, GitHub said "We don't support that file type. Try again with a GIF, JPEG, JPG, MOV, MP4, PNG, SVG, WEBM, CSV, DOCX, FODG, FODP, FODS, FODT, GZ, LOG, MD, ODF, ODG, ODP, ODS, ODT, PATCH, PDF, PPTX, TGZ, TXT, XLS, XLSX, or ZIP." Example Configuration.zip
This is the code in the zip file above.
Configuration NotepadDemo
{
param ()
Import-DscResource –ModuleName 'PSDesiredStateConfiguration'
Import-DscResource -ModuleName 'PSDscResources'
Node localhost
{
File Notepad {
DestinationPath ="C:\Windows\notepad.exe"
Ensure ="Present"
}
}
}
NotepadDemo
You have to remove the import of PSDesiredStateConfiguration in this case, and just ignore the warning message that is outputted. This is because the File
resource is not part of PSDscResource
.
Resource name 'Archive' is already being used by another Resource or Configuration. As I understand, problem same as https://github.com/PowerShell/PSDscResources/issues/88
Details of the scenario you tried and the problem that is occurring
Try to run generate MOF-files
Verbose logs showing the problem
Suggested solution to the issue
N/A
The DSC configuration that is used to reproduce the issue (as detailed as possible)
The operating system the target node is running
Version and build of PowerShell the target node is running
Version of the DSC module that was used ('dev' if using current dev branch)
current