# Windows Updates via DSC

**URL:** <https://forums.powershell.org/t/windows-updates-via-dsc/11400>\
**Category:** DSC\
**Created:** [October 2, 2018, 7:50am UTC](https://forums.powershell.org/t/windows-updates-via-dsc/11400 "2018-10-02T07:50:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mr-d-j-tracey](https://avatars.discourse-cdn.com/v4/letter/m/8dc957/32.png) [@mr-d-j-tracey](https://forums.powershell.org/u/mr-d-j-tracey)\
**Post date:** [October 2, 2018, 7:50am UTC](https://forums.powershell.org/t/windows-updates-via-dsc/11400/1 "2018-10-02T07:50:27Z")

</div>

Hi guys,

I’m using this DSC script as part of an automated (packer) OS build:

[http://theitrub.com/2017/01/microsoft-desired-state-configuration-install-all-windows-update-services-patches/#comment-148](http://theitrub.com/2017/01/microsoft-desired-state-configuration-install-all-windows-update-services-patches/#comment-148)

My issue is that when I run:

```
Start-DscConfiguration -Path ConfigName -Wait -Force -Verbose
```

…the DSC fires successfully, it triggers the download / install of the patches (e.g. the latest 1GB CU for Windows 2016) - but then the Start-DscConfiguration immediately returns - leaving the patch to download/install in the background.

The issue being that my build then assumes that the process is complete, the node is compliant and continues to shut the machine down for templating.

Question is - is there an amendment I can make to the logic of the script to not exit until the patches are installed, or if not, is there a reliable way to continually check for compliance, and not move on until compliance is met?

Thanks,

DanT

---

<div class="post-metadata">

**Author:** ![donj](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/donj/32/137_2.png) [@donj](https://forums.powershell.org/u/donj)\
**Post date:** [October 2, 2018, 9:10am UTC](https://forums.powershell.org/t/windows-updates-via-dsc/11400/2 "2018-10-02T09:10:48Z")

</div>

Huh. See, the thing about DSC is “eventual compliance.” It’s not designed to be part of a synchronous process, per se. You’re meant to kind of let it alone to do its thing. I suppose you could create a custom resource that keeps returning non-compliant every time it’s checked, until the patch process is complete. You’d need to find some service or registry key or process or something it could “ping” to determine that. And the custom resource’s “Set” wouldn’t actually do anything, just its “Test” and “Get.”

---

<div class="post-metadata">

**Author:** ![mr-d-j-tracey](https://avatars.discourse-cdn.com/v4/letter/m/8dc957/32.png) [@mr-d-j-tracey](https://forums.powershell.org/u/mr-d-j-tracey)\
**Post date:** [October 2, 2018, 9:18am UTC](https://forums.powershell.org/t/windows-updates-via-dsc/11400/3 "2018-10-02T09:18:29Z")

</div>

Thanks Don,

I get that what i’m doing isn’t exactly the best use case for DSC - but i’ve DSC’d everything else in the build, and it seems a shame to jump back into a ‘basic’ PowerShell task for this one step!

In any case - the DSC Windows Update script is great once the machine is out in the wild, in an environment without SCCM.

Thanks again for your time.

Dan

---

<div class="post-metadata">

**Author:** ![hans-o-martinsen](https://avatars.discourse-cdn.com/v4/letter/h/eada6e/32.png) [@hans-o-martinsen](https://forums.powershell.org/u/hans-o-martinsen)\
**Post date:** [October 16, 2018, 12:37pm UTC](https://forums.powershell.org/t/windows-updates-via-dsc/11400/4 "2018-10-16T12:37:07Z")

</div>

Hi.

&nbsp;

I use a similar script to do what you need here. It is doing a lot more as well, so it would not make sense to post it here. But the short of it is:

I use the module PSWindowsUpdate on the LCM side to do the actual patching. (Invoked from an xScript). That will block the running of the LCM until it is finished.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 9:16pm UTC](https://forums.powershell.org/t/windows-updates-via-dsc/11400/5 "2024-05-16T21:16:24Z")

</div>

Closed on May 16, 2024, 9:16pm UTC


