You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<liclass=" active "><ahref="/blog/dsc-is-dead-long-live-dsc/">DSC is Dead</a>
199
199
</li>
200
+
<liclass=" active "><ahref="/blog/your-first-class-based-microsoft-dsc-v3-resource/">Your first class-based Microsoft DSC v3 resource</a>
201
+
</li>
200
202
<liclass=" active "><ahref="/blog/convert-tests-to-pester5-for-dsc-community-repository/">Convert tests to Pester 5 for a DSC Community repository</a>
201
203
</li>
202
204
<liclass=" active "><ahref="/blog/convert-master-to-main/">Steps to rename master branch to main for a DSC Community resource</a>
@@ -353,12 +355,8 @@ <h2>Class Based DSC Resource only proposal</h2>
353
355
<p>The suggested change was only for DSC Resources schema, and no changes to MOF compilations was announced for now. Removing the CIM/MI/MOF code and dependency is definitely an overarching goal for PowerShell, but it won’t happen overnight.</p>
354
356
<p>Let’s add that when we mention change to PowerShell, it only affects the version 7.2 and up. <strong>Windows PowerShell 5.1 will (mostly) be untouched and unaffected</strong>.</p>
355
357
<p>After discussing the matter with the community via the GitHub issues, Twitter, and the DSC Community Call, the Powershell team published a change of direction: they intend to <ahref="https://github.com/PowerShell/PowerShell/issues/13731">start with supporting DSC Class based resources only</a> (but are still open for discussion).</p>
@@ -426,8 +424,7 @@ <h3 id="why-mof-and-cim-to-begin-with">Why MOF and CIM, to begin with?</h3>
426
424
Bear in mind PS 5.1 is set in stone, so it won’t get updated.</p>
427
425
<p>And that leads us to <strong>the major flaw</strong>, in my opinion, for <ahref="https://github.com/PowerShell/PowerShell/issues/13359">the former JSON-based DSC resource proposal</a>: We’d have to replace the <code>[Microsoft.Management.Infrastructure.CimInstance[]]</code> with <code>[PSObject]</code>.</p>
428
426
<blockquote>
429
-
<p>With this change, embedded objects passed to Get/Set/Test will be PSObjects instead of CimInstances. Unless the script is explicitly checking that it is a CimInstance, existing code should work with PSObject.</p>
430
-
</blockquote>
427
+
<p>With this change, embedded objects passed to Get/Set/Test will be PSObjects instead of CimInstances. Unless the script is explicitly checking that it is a CimInstance, existing code should work with PSObject.</p></blockquote>
431
428
<p>Doing so would <strong>break compatibility between PS 5.1 and PS 7+</strong> for any resource using such subtypes / embedded objects.</p>
432
429
<p>Using class-based DSC resource, and the <code>if {} else {}</code> workaround I mentioned above, would support greater backward compatibility scenarios.</p>
433
430
<p>Obviously, there’s still a lot of differences between PS5.1 and PS7 which means for some resources it may not be possible to be used in PS7 anyway<br>
@@ -450,12 +447,8 @@ <h2 id="dsc-community-does-not-use-class-based-resources">DSC Community does not
450
447
<p>Since then we had a DSC Community call were Bartek Bielawski (<ahref="https://twitter.com/bielawb?lang=en">@bielawb</a> on Twitter) came to <ahref="https://youtu.be/r-eKNZ7iEfw?t=172">present on the class resources</a> that he’s been using in production for a while (along with Daniel Both <ahref="https://twitter.com/poshboth">@poshboth</a>).<br>
451
448
We also got more experience with Class-based resource with <ahref="https://github.com/dsccommunity/JeaDsc/tree/master/source/DSCClassResources"><code>JeaDsc</code></a>, although it’s not the approach I would <em>recommend</em> today. Great experience nonetheless, and great work.</p>
452
449
<p>We’ve made several changes to our pipeline automation, and getting to a point (soon) where adding DSC Class Resource should be easier.</p>
</span></span></code></pre></div><p>Worth noting, Jakub Jares (<ahref="https://twitter.com/nohwnd">@nohwnd</a>, the maintainer of Pester) is <ahref="https://twitter.com/nohwnd/status/1308715571756912640?s=20">suggesting to build this in Pester 5</a> (go upvote now, please).</p>
483
476
<blockquote>
484
-
<p><ahref="https://twitter.com/nohwnd/status/1308752521142435842?s=20"><em>@nowhnd:</em></a> The api would probably look like this: Mock -Type ([DateTime]) -Property Now -Get <thevalue> But imho the final form is not that important. It does work on PowerShell classes. In the end you should be able to use this to replace almost any method and property.</p>
485
-
</blockquote>
477
+
<p><ahref="https://twitter.com/nohwnd/status/1308752521142435842?s=20"><em>@nowhnd:</em></a> The api would probably look like this: Mock -Type ([DateTime]) -Property Now -Get <thevalue> But imho the final form is not that important. It does work on PowerShell classes. In the end you should be able to use this to replace almost any method and property.</p></blockquote>
486
478
<p>Again, that’s definitely something that we will work on and document, but I don’t see this as a major obstacle.<br>
487
479
We could also mock by inheriting the class and overridding that method.</p>
488
480
<p>Now, I’d like to slide-in another opinion, which might be unpopular, but your DSC Resource PSM1 or Class should not be thousands of lines long.<br>
0 commit comments