Comments (5)
@Borgquite since I spent time to identify the problem it was almost a sin not to do a PR ;-)
from microsoft365dsc.
@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.
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.
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.
@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)
- ENHANCEMENT / FEATURE REQUEST - Filter on Property HOT 3
- Clarification on Setting Execution Policy for Microsoft 365 DSC HOT 2
- NewResourceName: Intune Apple iPadOS/iOS Device feature policies
- NewResourceName: Intune Apple custom iPadOS/iOPS device configuration profiles
- IntuneApplicationControlPolicyWindows10: App Control for Business (preview) policies are not in the export.
- Assert-M365DSCBlueprint Not Reporting Missing Included Roles HOT 1
- AADUser resource incomplete HOT 1
- SCDLPComplianceRule: Attributes are missing when exporting
- Problem with uploading exchange configuration
- C'est
- Can event log be disabled when use DSC? HOT 1
- BUG?: [SPOSharingSettings] Settings appear to apply, except for RequireAcceptingAccountMatchInvitedAccount = $True HOT 7
- SPOSite: Unable to export the SharingDomainRestrictionMode & SharingAllowedDomainList settings
- AADConditionalAccessPolicy with TermsOfUse failed to create
- AADGroupOwnerConsentSettings is still a valid resource according to the website HOT 1
- Export: Unable to create reports from configuration exports HOT 2
- Your app has been throttled by AAD due to too many requests. HOT 10
- IntuneDeviceConfigurationDefenderForEndpointOnboardingPolicyWindows10: Error in catch block overwrites/hides original error?
- AADGroup: New group creation failing due to AssignedToRole parameter not found in the first run
- Problem exporting OrgSettings and PPTenantIsolationSettings HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from microsoft365dsc.