Code Monkey home page Code Monkey logo

Comments (3)

PlagueHO avatar PlagueHO commented on September 6, 2024 2

Hi @begna112 - thanks for raising this and apologies for the very long delay in getting back to you. The Set-StrictMode setting was added to the PSDscResource and xPSDesiredStateConfiguration to ensure the PS code within the resource was of high quality and reduce bugs. However, as you point out this does result in any code executed by the Script resource to also adhere to this convention - specifically in your examples that variables are declared before use.

Because the PSDscResource module must remain feature compatible with the in-box PSDesiredStateConfiguration module, it won't likely have any new parameters added to it. This is not the case for the community maintained xPSDesiredStateConfiguration module.

One of the goals moving from PSDesiredStateConfiguration to PSDscResources was to minimize impact, but due to the nature of the move (lots of code was improved and bugs fixed) some DSC config changes was going to be possible. However, it was understood that some configs would require minor changes.

The move away from Set-StrictMode for this module and the xPSDesiredStateConfiguration isn't likely to be done due to the increased difficulty in maintaining a high quality.

However, installing PSDscResources onto a machine should not cause it to be replaced throughout as long as you've specified the resource module to import in your DSC config unless you installed the module to $PSHome (https://docs.microsoft.com/en-us/powershell/scripting/dsc/configurations/import-dscresource?view=powershell-5.1). Can you check you're installing these modules into a location where they won't be automatically imported by PS DSC?

from psdscresources.

begna112 avatar begna112 commented on September 6, 2024

Because the PSDscResource module must remain feature compatible with the in-box PSDesiredStateConfiguration module, it won't likely have any new parameters added to it.

If that is the case, why would you change the Strict Mode setting? These changes are specifically breaking compatibility with PSDesiredStateConfiguration in Script resources, and possibly in others, like the Registry resource example above. (It's been so long since I tested that, but I'm fairly certain that it worked as expected without Force, evaluating as True when the value was already correctly set. Whereas with Strict Mode, it gave the error.)

Can you check you're installing these modules into a location where they won't be automatically imported by PS DSC?

Modules/DscResources are installed in C:\Program Files\WindowsPowerShell\Modules\.

from psdscresources.

johlju avatar johlju commented on September 6, 2024

This will most likely not change in this module, but for the xPSDesiredStateConfiguration we could move the strict check to the unit tests so strict mode is checked during the test phase, and so it is not used during runtime. Suggest opening an issue in the repo for xPSDesiredStateConfiguration so it can b tracked, and then please send in a PR to xPSDesiredStateConfiguration that make the correct changes to the unit tests and code.

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.