microsoft / winget-dsc

MIT License
23 stars 14 forks source link

Windows settings update #93

Open Gijsreyn opened 2 weeks ago

Gijsreyn commented 2 weeks ago

Addresses the Microsoft.Windows.Setting.WindowsUpdate on #34

Gijsreyn commented 2 weeks ago

@denelon Hello, I thought giving a shot on the Windows Update settings. Althought I came pretty far and I left the PR as draft, there are some oddities I need help with. Hopefully you (or others) can help me out:

  1. When setting the delivery optimization settings through the UI, additional registry keys are created:

image

I couldn't find any relevant documentation if these keys are actually required, or if the keys that are being set now, are sufficient.

  1. The delivery optimization settings require elevation to be read
  2. I attempted to mimic the work of Stephen in the test. Unfortunately, Pester only creates a hive in HKCU. All settings that we attempt to set, are done in HKLM or HKU.
denelon commented 2 weeks ago

@crutkas and I have been working on some of the challenges with Windows update for his setup. There are some new ACL changes associated with some registry keys in newer versions of Windows, and we've been working on the "right" way to do this.

I don't know if you've seen the experimental "configureSelfElevate" feature in WinGet, but if you decorate the configuration file appropriately, you'll get a single UAC when running a configuration with one or more resources requiring elevation. That doesn't really help with the challenges here, but it's worth mentioning.

Gijsreyn commented 2 weeks ago

That's pretty cool Demitrius. If you have any insights already what keys require to be targeted, I can include them already if the build version is higher than ...

I'm learning every day, thanks for sharing. If you have any links to the experimental features, I will check it out :)

Little off topic. I like the setup what I'm seeing. I was working with DevHome. While I like the GUI, you can guess by now that I also love to automate as much as possible. My setup is a bit different compared to the one from Clint. Because I opted to use the DevHome Hyper-V option, I tried to automate it with DSC resources. It's a combination between the HyperVDsc module, dsc.exe, winget.exe, and some PowerShell code.

When attempting to set it up, I found myself creating a bunch of PowerShell script already. I really wanted to add it either on the DevHome repository, or here demonstrating a combination between multiple orchestrations tools. That brings me already to the point you've already mentioned already during your PSConfEU 2024 presentation. There are still pain points to fully automate it.

To sum it up some of the notes I took:

denelon commented 2 weeks ago

Experimental features in WinGet can be found using winget features. If you run winget features --help or winget features -? you'll get the link to the help document at GitHub.

Yeah, there are still plenty of rough edges leading you to use the Script resource. We're trying to find the examples where that's necessary so we can reason through gaps in implementation or missing DSC Resources.

Secrets are always a challenge when using Configuration as Code. Lots of products default with no password or a well-known password, and it's a bit tricky to ensure they aren't present in configuration files. This is definitely an area we will need to explore further to come up with some best-practices and model them.

I'll reach out to the PowerShell team to see what they are thinking in regard to PSResourceGet and installing modules.

denelon commented 2 weeks ago

Related to:

Gijsreyn commented 2 weeks ago

Demitrius, can I put this PR on review to get some assistance on writing unit tests, and get an alpha release available somewhere?

denelon commented 2 weeks ago

You bet :)

crutkas commented 2 weeks ago

Can’t wait to try this out!

Gijsreyn commented 2 weeks ago

@ryfu-msft Hey champ, can you take a look with your magic eyes and hopefully give me some assistance in writing Pester tests?

github-actions[bot] commented 2 weeks ago

@check-spelling-bot Report

:red_circle: Please review

See the :open_file_folder: files view, the :scroll:action log, or :memo: job summary for details.

Unrecognized words (3)

Bandwith PCs wmiprvse

These words are not needed and should be removed Toolpackage

To accept these unrecognized words as correct and remove the previously acknowledged and now absent words, you could run the following commands ... in a clone of the [git@github.com:Gijsreyn/winget-dsc.git](https://github.com/Gijsreyn/winget-dsc.git) repository on the `windows-update-setting` branch ([:information_source: how do I use this?]( https://docs.check-spelling.dev/Accepting-Suggestions)): ``` sh curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.24/apply.pl' | perl - 'https://github.com/microsoft/winget-dsc/actions/runs/11695848747/attempts/1' ```
Pattern suggestions :scissors: (3) You could add these patterns to `.github/actions/spelling/patterns.txt`: ``` # Automatically suggested patterns # hit-count: 15 file-count: 6 # Compiler flags (?:^|[\t ,"'`=(])-[DPWXYLlf](?=[A-Z]{2,}|[A-Z][a-z]|[a-z]{2,}) # hit-count: 3 file-count: 1 # githubusercontent /[-a-z0-9]+\.githubusercontent\.com/[-a-zA-Z0-9?&=_\/.]* # hit-count: 2 file-count: 1 # GitHub SHAs (markdown) (?:\[`?[0-9a-f]+`?\]\(https:/|)/(?:www\.|)github\.com(?:/[^/\s"]+){2,}(?:/[^/\s")]+)(?:[0-9a-f]+(?:[-0-9a-zA-Z/#.]*|)\b|) ```
Notices (1) #### See the [:open_file_folder: files](https://github.com/microsoft/winget-dsc/pull/93/files/) view, the [:scroll:action log](https://github.com/microsoft/winget-dsc/actions/runs/11695848747/job/32571947121#step:4:1), or [:memo: job summary](https://github.com/microsoft/winget-dsc/actions/runs/11695848747/attempts/1#summary-32571947121) for details. [:information_source: Notices](https://docs.check-spelling.dev/Event-descriptions) | Count -|- [:information_source: candidate-pattern](https://docs.check-spelling.dev/Event-descriptions#candidate-pattern) | 5 See [:information_source: Event descriptions](https://docs.check-spelling.dev/Event-descriptions) for more information.
If the flagged items are :exploding_head: false positives If items relate to a ... * binary file (or some other file you wouldn't want to check at all). Please add a file path to the `excludes.txt` file matching the containing file. File paths are Perl 5 Regular Expressions - you can [test]( https://www.regexplanet.com/advanced/perl/) yours before committing to verify it will match your files. `^` refers to the file's path from the root of the repository, so `^README\.md$` would exclude [README.md]( ../tree/HEAD/README.md) (on whichever branch you're using). * well-formed pattern. If you can write a [pattern](https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples:-patterns) that would match it, try adding it to the `patterns.txt` file. Patterns are Perl 5 Regular Expressions - you can [test]( https://www.regexplanet.com/advanced/perl/) yours before committing to verify it will match your lines. Note that patterns can't match multiline strings.
github-actions[bot] commented 2 weeks ago

@check-spelling-bot Report

:red_circle: Please review

See the :open_file_folder: files view, the :scroll:action log, or :memo: job summary for details.

Unrecognized words (2)

PCs wmiprvse

These words are not needed and should be removed Toolpackage

To accept these unrecognized words as correct and remove the previously acknowledged and now absent words, you could run the following commands ... in a clone of the [git@github.com:Gijsreyn/winget-dsc.git](https://github.com/Gijsreyn/winget-dsc.git) repository on the `windows-update-setting` branch ([:information_source: how do I use this?]( https://docs.check-spelling.dev/Accepting-Suggestions)): ``` sh curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.24/apply.pl' | perl - 'https://github.com/microsoft/winget-dsc/actions/runs/11695906778/attempts/1' ```
Pattern suggestions :scissors: (3) You could add these patterns to `.github/actions/spelling/patterns.txt`: ``` # Automatically suggested patterns # hit-count: 15 file-count: 6 # Compiler flags (?:^|[\t ,"'`=(])-[DPWXYLlf](?=[A-Z]{2,}|[A-Z][a-z]|[a-z]{2,}) # hit-count: 3 file-count: 1 # githubusercontent /[-a-z0-9]+\.githubusercontent\.com/[-a-zA-Z0-9?&=_\/.]* # hit-count: 2 file-count: 1 # GitHub SHAs (markdown) (?:\[`?[0-9a-f]+`?\]\(https:/|)/(?:www\.|)github\.com(?:/[^/\s"]+){2,}(?:/[^/\s")]+)(?:[0-9a-f]+(?:[-0-9a-zA-Z/#.]*|)\b|) ```
Notices (1) #### See the [:open_file_folder: files](https://github.com/microsoft/winget-dsc/pull/93/files/) view, the [:scroll:action log](https://github.com/microsoft/winget-dsc/actions/runs/11695906778/job/32572107439#step:4:1), or [:memo: job summary](https://github.com/microsoft/winget-dsc/actions/runs/11695906778/attempts/1#summary-32572107439) for details. [:information_source: Notices](https://docs.check-spelling.dev/Event-descriptions) | Count -|- [:information_source: candidate-pattern](https://docs.check-spelling.dev/Event-descriptions#candidate-pattern) | 5 See [:information_source: Event descriptions](https://docs.check-spelling.dev/Event-descriptions) for more information.
If the flagged items are :exploding_head: false positives If items relate to a ... * binary file (or some other file you wouldn't want to check at all). Please add a file path to the `excludes.txt` file matching the containing file. File paths are Perl 5 Regular Expressions - you can [test]( https://www.regexplanet.com/advanced/perl/) yours before committing to verify it will match your files. `^` refers to the file's path from the root of the repository, so `^README\.md$` would exclude [README.md]( ../tree/HEAD/README.md) (on whichever branch you're using). * well-formed pattern. If you can write a [pattern](https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples:-patterns) that would match it, try adding it to the `patterns.txt` file. Patterns are Perl 5 Regular Expressions - you can [test]( https://www.regexplanet.com/advanced/perl/) yours before committing to verify it will match your lines. Note that patterns can't match multiline strings.
github-actions[bot] commented 2 weeks ago

@check-spelling-bot Report

:red_circle: Please review

See the :open_file_folder: files view, the :scroll:action log, or :memo: job summary for details.

Unrecognized words (1)

wmiprvse

These words are not needed and should be removed Toolpackage

To accept these unrecognized words as correct and remove the previously acknowledged and now absent words, you could run the following commands ... in a clone of the [git@github.com:Gijsreyn/winget-dsc.git](https://github.com/Gijsreyn/winget-dsc.git) repository on the `windows-update-setting` branch ([:information_source: how do I use this?]( https://docs.check-spelling.dev/Accepting-Suggestions)): ``` sh curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.24/apply.pl' | perl - 'https://github.com/microsoft/winget-dsc/actions/runs/11695921074/attempts/1' ```
Pattern suggestions :scissors: (3) You could add these patterns to `.github/actions/spelling/patterns.txt`: ``` # Automatically suggested patterns # hit-count: 15 file-count: 6 # Compiler flags (?:^|[\t ,"'`=(])-[DPWXYLlf](?=[A-Z]{2,}|[A-Z][a-z]|[a-z]{2,}) # hit-count: 3 file-count: 1 # githubusercontent /[-a-z0-9]+\.githubusercontent\.com/[-a-zA-Z0-9?&=_\/.]* # hit-count: 2 file-count: 1 # GitHub SHAs (markdown) (?:\[`?[0-9a-f]+`?\]\(https:/|)/(?:www\.|)github\.com(?:/[^/\s"]+){2,}(?:/[^/\s")]+)(?:[0-9a-f]+(?:[-0-9a-zA-Z/#.]*|)\b|) ```
Notices (1) #### See the [:open_file_folder: files](https://github.com/microsoft/winget-dsc/pull/93/files/) view, the [:scroll:action log](https://github.com/microsoft/winget-dsc/actions/runs/11695921074/job/32572140842#step:4:1), or [:memo: job summary](https://github.com/microsoft/winget-dsc/actions/runs/11695921074/attempts/1#summary-32572140842) for details. [:information_source: Notices](https://docs.check-spelling.dev/Event-descriptions) | Count -|- [:information_source: candidate-pattern](https://docs.check-spelling.dev/Event-descriptions#candidate-pattern) | 5 See [:information_source: Event descriptions](https://docs.check-spelling.dev/Event-descriptions) for more information.
If the flagged items are :exploding_head: false positives If items relate to a ... * binary file (or some other file you wouldn't want to check at all). Please add a file path to the `excludes.txt` file matching the containing file. File paths are Perl 5 Regular Expressions - you can [test]( https://www.regexplanet.com/advanced/perl/) yours before committing to verify it will match your files. `^` refers to the file's path from the root of the repository, so `^README\.md$` would exclude [README.md]( ../tree/HEAD/README.md) (on whichever branch you're using). * well-formed pattern. If you can write a [pattern](https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples:-patterns) that would match it, try adding it to the `patterns.txt` file. Patterns are Perl 5 Regular Expressions - you can [test]( https://www.regexplanet.com/advanced/perl/) yours before committing to verify it will match your lines. Note that patterns can't match multiline strings.
denelon commented 1 week ago

It looks like there are conflicts in this PR now. If you're still working on it, it might be best to convert it to a draft, but if you're ready for review, keep it open after you fix the conflicts :)

github-actions[bot] commented 1 week ago

@check-spelling-bot Report

:red_circle: Please review

See the :open_file_folder: files view, the :scroll:action log, or :memo: job summary for details.

Unrecognized words (2)

PCs wmiprvse

To accept these unrecognized words as correct, you could run the following commands ... in a clone of the [git@github.com:Gijsreyn/winget-dsc.git](https://github.com/Gijsreyn/winget-dsc.git) repository on the `windows-update-setting` branch ([:information_source: how do I use this?]( https://docs.check-spelling.dev/Accepting-Suggestions)): ``` sh curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.24/apply.pl' | perl - 'https://github.com/microsoft/winget-dsc/actions/runs/11849049742/attempts/1' ```
If the flagged items are :exploding_head: false positives If items relate to a ... * binary file (or some other file you wouldn't want to check at all). Please add a file path to the `excludes.txt` file matching the containing file. File paths are Perl 5 Regular Expressions - you can [test]( https://www.regexplanet.com/advanced/perl/) yours before committing to verify it will match your files. `^` refers to the file's path from the root of the repository, so `^README\.md$` would exclude [README.md]( ../tree/HEAD/README.md) (on whichever branch you're using). * well-formed pattern. If you can write a [pattern](https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples:-patterns) that would match it, try adding it to the `patterns.txt` file. Patterns are Perl 5 Regular Expressions - you can [test]( https://www.regexplanet.com/advanced/perl/) yours before committing to verify it will match your lines. Note that patterns can't match multiline strings.
github-actions[bot] commented 1 week ago

@check-spelling-bot Report

:red_circle: Please review

See the :open_file_folder: files view, the :scroll:action log, or :memo: job summary for details.

Unrecognized words (1)

finalstate

To accept these unrecognized words as correct, you could run the following commands ... in a clone of the [git@github.com:Gijsreyn/winget-dsc.git](https://github.com/Gijsreyn/winget-dsc.git) repository on the `windows-update-setting` branch ([:information_source: how do I use this?]( https://docs.check-spelling.dev/Accepting-Suggestions)): ``` sh curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.24/apply.pl' | perl - 'https://github.com/microsoft/winget-dsc/actions/runs/11849396360/attempts/1' ```
If the flagged items are :exploding_head: false positives If items relate to a ... * binary file (or some other file you wouldn't want to check at all). Please add a file path to the `excludes.txt` file matching the containing file. File paths are Perl 5 Regular Expressions - you can [test]( https://www.regexplanet.com/advanced/perl/) yours before committing to verify it will match your files. `^` refers to the file's path from the root of the repository, so `^README\.md$` would exclude [README.md]( ../tree/HEAD/README.md) (on whichever branch you're using). * well-formed pattern. If you can write a [pattern](https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples:-patterns) that would match it, try adding it to the `patterns.txt` file. Patterns are Perl 5 Regular Expressions - you can [test]( https://www.regexplanet.com/advanced/perl/) yours before committing to verify it will match your lines. Note that patterns can't match multiline strings.
Gijsreyn commented 1 week ago

Oops. I made a mistake. It should be fixed now. There are also tests added now and while adding the test, I found two caveats, which were quite interesting. If there are any suggestions on it to do it differently, then please let me know.

Originally I designed the validation checking within a function. This was replaced after the suggestion of Kaleb: 7ed2c35. Here came the challenge: when performing testing, when the validation is not within the range of of zero, it cannot grab the original state. That's why I added an additional check in when that particalur property is set. Second challenge was the fact that when specifying either Pct/Bps, it throws an error. Now I'm simply removing the parameters. I'm going to be honest here, there is some rework in here which I totally miscalculate. If either set is provided as properties, it should remove the others, otherwise both settings don't work.

Because the pull request is already quite large, I hope it can be pulled in. I'll fix this one later and add it as TODO on #104 . If not, please let me know.