Giter VIP home page Giter VIP logo

Comments (5)

salbeck-sit avatar salbeck-sit commented on July 20, 2024 1

@Borgquite since I spent time to identify the problem it was almost a sin not to do a PR ;-)

from microsoft365dsc.

Borgquite avatar Borgquite commented on July 20, 2024

@andikrueger @ykuijs @salbeck-sit Can you help here please, again. As you know I've been trying to use this resource on many occasions and each time I do something new, basic bugs just keep on coming (#2633, #2704, #2775, #2776, #3194). I am again wondering whether your unit and integration tests are anywhere near appropriate.

I tried this fix this myself and as far as I can tell Get-TargetResource is returning 'Ensure = Absent' if Absent is left blank, regardless of whether or not the AU exists. But:

  • Running Get-DscConfiguration is currently broken for me (The PowerShell DSC resource returned results that are not valid from Get-TargetResource. The Verbose key is not a valid property in the corresponding DSC resource schema file. The results from Get-TargetResource must be in a Hashtable format. The keys in the Hashtable must be the same as the properties in the corresponding DSC resource schema file.)
  • I can see that Test-TargetResource calls Get-TargetResource - but when I try to debug this using -Verbose, for some reason I don't see the output from the Write-Verbose calls in that function (I do get them for Test-TargetResource).
  • Just trying to get a basic understanding of how GetTargetResource works here - as far as I can tell, lines 99-116 are entirely pointless - writing something to $getValue then setting it back to $null?

If someone can untangle this mess, I'd appreciate it. At present I hate touching Microsoft365DSC, it never, ever 'just works'.

from microsoft365dsc.

Borgquite avatar Borgquite commented on July 20, 2024

Oh and I should have said - currently if you run Start-DscConfiguration on the test resource in this bug, you end up with multiple AdministrativeUnits created. So basically, for this resource, if Ensure is left blank, idempotency is broken.

from microsoft365dsc.

Borgquite avatar Borgquite commented on July 20, 2024

Ah, just figured something out. The whole of Get-TargetResource is basically one huge try {} catch (from line 101 to 273). When attempting to create an AADAdministrativeUnit from scratch without an ID, this always fails on line 108, and bumps down to line 275, returning an error.

I'm not sure how to fix this - help?

from microsoft365dsc.

salbeck-sit avatar salbeck-sit commented on July 20, 2024

@Borgquite I think the issue with leaving Ensure blank is that it then isn't part of $PSBoundParameters. See https://ss64.com/ps/psboundparameters.html
This affects Test-TargetResource in line 898 where the Ensure-value from Get-TargetResource is compared to $PSBoundParameters.Ensure.
This will always fail if Ensure is not explicitly stated in the config, leading to an 'indiscriminate' call to Set-TargetResource
However, I don't see any similar construct in Set-TargetResource where tests are done against $Ensure.
But, as you've noticed, a call without an ID will cause Get-TargetResource to return null due to the block of lines 105-118 which should absolutely be removed.
The missing verbose output is due to the Verbose-switch being stripped from PSBoundParameters in line 391 before calling Get-TargetResource
I'm a bit pressed for time for the next 2-3 weeks so I can't offer to fix the resource.

from microsoft365dsc.

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.