dsccommunity / ComputerManagementDsc

DSC resources for for configuration of a Windows computer. These DSC resources allow you to perform computer management tasks, such as renaming the computer, joining a domain and scheduling tasks as well as configuring items such as virtual memory, event logs, time zones and power settings.
https://dsccommunity.org
MIT License
303 stars 83 forks source link

BREAKING CHANGE: PSResourceRepository: Resource to manage PowerShell Package Repositories #395

Closed nickgw closed 1 year ago

nickgw commented 1 year ago

Pull Request (PR) description

New resources to manage PowerShell repositories and PowerShell modules:

This Pull Request (PR) fixes the following issues

Task list


This change is Reviewable

codecov[bot] commented 1 year ago

Codecov Report

Merging #395 (c45096a) into main (6c3f2fd) will decrease coverage by 1%. The diff coverage is n/a.

Impacted file tree graph

@@         Coverage Diff          @@
##           main   #395    +/-   ##
====================================
- Coverage    90%    89%    -2%     
====================================
  Files        17     18     +1     
  Lines      1726   1940   +214     
====================================
+ Hits       1564   1730   +166     
- Misses      162    210    +48     
Impacted Files Coverage Δ
source/ComputerManagementDsc.psm1 77% <ø> (ø)
nickgw commented 1 year ago

Reviewable status: 0 of 20 files reviewed, 1 unresolved discussion (waiting on @nickgw)

_tests/Unit/DSC_Computer.Tests.ps1 line 1407 at r2 (raw file):_

                            -Credential $credential`
                            -Verbose
                    } | Should -Throw $message

I think removing this block has broken the tests. Was that intentional?

Thanks, don't know how that made it in!

johlju commented 1 year ago

With the latest changes in this PR I can run the resource. Running the below on a lab server with Invoke-DscResource (which invokes LCM, so in Windows PowerShell):

The errors are to the fact that this lab server has no access to Internet. But the resource does not throw any errors other than expected.

 Invoke-DscResource -ModuleName ComputerManagementDsc -Name PSResourceRepository -Method Get -Property @{
    Name                      = 'PSGallery'
    SourceLocation            = 'https://www.powershellgallery.com/api/v2'
} -Verbose 
VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = ResourceGet,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' = root/Microsoft
/Windows/DesiredStateConfiguration'.
VERBOSE: An LCM method call arrived from computer SQL01 with user sid S-1-5-21-1949799417-2769522740-2476083923-1107.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\
PSModule.psm1'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Getting the current state for resource 'PSResourceRepository' using the key property '{"Name":"PSGallery"}'. (RB0001)
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Return the current state of the repository 'PSGallery'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\PackageManagement.psd1'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Loading 'FormatsToProcess' from path 'C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\PackageManagement.format.ps1xml'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PowerShell.PackageManagement.dll'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting cmdlet 'Find-Package'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting cmdlet 'Get-Package'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting cmdlet 'Get-PackageProvider'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting cmdlet 'Get-PackageSource'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting cmdlet 'Install-Package'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting cmdlet 'Import-PackageProvider'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting cmdlet 'Find-PackageProvider'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting cmdlet 'Install-PackageProvider'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting cmdlet 'Register-PackageSource'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting cmdlet 'Save-Package'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting cmdlet 'Set-PackageSource'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting cmdlet 'Uninstall-Package'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting cmdlet 'Unregister-PackageSource'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Importing cmdlet 'Find-Package'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Importing cmdlet 'Find-PackageProvider'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Importing cmdlet 'Get-Package'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Importing cmdlet 'Get-PackageProvider'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Importing cmdlet 'Get-PackageSource'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Importing cmdlet 'Import-PackageProvider'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Importing cmdlet 'Install-Package'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Importing cmdlet 'Install-PackageProvider'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Importing cmdlet 'Register-PackageSource'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Importing cmdlet 'Save-Package'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Importing cmdlet 'Set-PackageSource'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Importing cmdlet 'Uninstall-Package'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Importing cmdlet 'Unregister-PackageSource'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'Publish-Module'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'Find-Module'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'Save-Module'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'Install-Module'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'Update-Module'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'Uninstall-Module'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'Get-InstalledModule'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'Find-DscResource'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'Find-Command'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'Find-RoleCapability'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'Publish-Script'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'Find-Script'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'Save-Script'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'Install-Script'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'Update-Script'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'Uninstall-Script'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'Get-InstalledScript'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'Register-PSRepository'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'Set-PSRepository'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'Unregister-PSRepository'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'Get-PSRepository'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'Test-ScriptFileInfo'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'New-ScriptFileInfo'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'Update-ScriptFileInfo'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'Get-PackageProviderName'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'Get-Feature'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'Initialize-Provider'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'Get-DynamicOptions'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'Add-PackageSource'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'Resolve-PackageSource'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'Remove-PackageSource'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'Find-Package'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'Download-Package'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'Install-Package'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'Uninstall-Package'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'Get-InstalledPackage'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting function 'Update-ModuleManifest'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting alias 'fimo'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting alias 'inmo'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting alias 'upmo'.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Exporting alias 'pumo'.
WARNING: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] MSG:UnableToDownload «https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409» «»
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Cannot download link 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409', retrying for '2' more times.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Cannot download link 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409', retrying for '1' more times.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Cannot download link 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409', retrying for '0' more times.
WARNING: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] Unable to download the list of available providers. Check your internet connection.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] The repository 'PSGallery' was not found.
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] NOTMATCH: Value (type 'InstallationPolicy') for property 'InstallationPolicy' does not match. Current state is '' and desired state is 'Untrusted'. (DRC0021)
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] MATCH: Value (type 'System.String') for property 'Name' does match. Current state is 'PSGallery' and desired state is 'PSGallery'. (DRC0020)
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] NOTMATCH: Value (type 'Ensure') for property 'Ensure' does not match. Current state is 'Absent' and desired state is 'Present'. (DRC0021)
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] MATCH: Value (type 'System.String') for property 'SourceLocation' does match. Current state is 'https://www.powershellgallery.com/api/v2' and desired state is 'https://www.powershellgallery.com/api/v2'. (DRC0020)
VERBOSE: [SQL01]:                            [[PSResourceRepository]DirectResourceAccess] NOTMATCH: Value (type 'System.String') for property 'PackageManagementProvider' does not match. Current state is '' and desired state is 'NuGet'. (DRC0021)
VERBOSE: [SQL01]: LCM:  [ End    Get      ]  [[PSResourceRepository]DirectResourceAccess]  in 21.1520 seconds.
VERBOSE: [SQL01]: LCM:  [ End    Set      ]    in  21.9270 seconds.
VERBOSE: Operation 'Invoke CimMethod' complete.

ConfigurationName         : 
DependsOn                 : 
ModuleName                : ComputerManagementDsc
ModuleVersion             : 8.6.0
PsDscRunAsCredential      : 
ResourceId                : 
SourceInfo                : 
Credential                : 
Ensure                    : Absent
InstallationPolicy        : Untrusted
Name                      : PSGallery
PackageManagementProvider : NuGet
Proxy                     : 
ProxyCredential           : 
PublishLocation           : 
Registered                : False
ScriptPublishLocation     : 
ScriptSourceLocation      : 
SourceLocation            : https://www.powershellgallery.com/api/v2
Trusted                   : False
PSComputerName            : localhost

VERBOSE: Time taken for configuration job to complete is 22.197 seconds
johlju commented 1 year ago

@PlagueHO the HQRM test does not pass if minimum PowerShell version is 4.0. So should we

  1. Move to 5.0 and make a breaking change?
  2. Keep 4.0 to avoid a breaking change (and document that class-based resources need 5.0) but exclude the tag Common Tests - Module Manifest in build.yaml? (and move to 5.0 at a later date)
nickgw commented 1 year ago

@PlagueHO the HQRM test does not pass if minimum PowerShell version is 4.0. So should we

  1. Move to 5.0 and make a breaking change?
  2. Keep 4.0 to avoid a breaking change (and document that class-based resources need 5.0) but exclude the tag Common Tests - Module Manifest in build.yaml? (and move to 5.0 at a later date)

fwiw both DnsServerDsc and SqlServerDsc bumped to 5.0, sql in 2017 and dns when the module was renamed from xdns in 2021 and the first cbr was added.

would wmf4.0 be able to import the module anyway, since class was introduced in 5.0?

PlagueHO commented 1 year ago

Yeah, agree! We should bump this to PowerShell 5.0.

We should add a "Requirements" to the README.md. For example: https://github.com/dsccommunity/DFSDsc#requirements

Just make it a breaking change.

johlju commented 1 year ago

@nickgw awesome work on this! I continue the review when these comments are resolved. Just tag me if you want to discuss something.

nickgw commented 1 year ago

Hey @johlju , I think I've resolved / hit all your comments!

johlju commented 1 year ago

@nickgw it seems integration tests for 2019 fails for some reason. It says it did not found that resource that was run just seconds before. 🙂 I kicked off that job again to see if it fails again. Sometimes the integration tests fail with intermittent errors because we run Set, Get, and Test so quickly after each other...

nickgw commented 1 year ago

@johlju whenever you get a chance, I've updated / responded to your review!

johlju commented 1 year ago

Will continue the review this weekend. 🙂

johlju commented 1 year ago

I saw a couple of strange behaviors in the integration tests, added review comments for them. Maybe I'm to tired and couldn't think straight. 🙂

kilasuit commented 1 year ago

Honestly not sure that this should be part of this repo and whether or not that @SydneyhSmith & the PowerShellGet team have planned for this in future (as I've been a little outta the loop as of late)

johlju commented 1 year ago

We have thought about that. If that happens, when it is out of preview, that day we can deprecate what this PR proposes. 🙂

johlju commented 1 year ago

@nickgw will continue the review as soon as I have time.

kilasuit commented 1 year ago

@johlju thanks for your comment as that makes things clearer to me & like I said I've been a bit outta the loop for personal reasons this year so thought it only worth a mention just incase it hadn't been thought about, though I perhaps should have trusted a bit more that it would have been, but always better to say something than not do so, right?

nickgw commented 1 year ago

@johlju I'm having trouble figuring out why the integration PSRepository_Create_Default_Config is failing on the build runner with

Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2'; IsTrusted = 'False'; IsRegistered = 'True'.
      [-] Should compile and apply the MOF without throwing 3.14s
        Expected no exception to be thrown, but an exception "Value cannot be null." was thrown from D:\a\1\s\tests\Integration\Classes\PSResourceRepository.integration.tests.ps1:118 char:21
            + ...               Start-DscConfiguration @startDscConfigurationParameters
            +                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.
        119:                 } | Should -Not -Throw

I've run this exact same code on my test machine and it works fine

johlju commented 1 year ago

Guessing it is the line Register-PSRepository -Default that fails? Could we add -Verbose -Debug to that command to see if we get more output? Could it be that we need to pass InstallationPolicy even though it is optional?

Syntax from the help:

Register-PSRepository
        [-Default]
        [-InstallationPolicy <String>]
        [-Proxy <Uri>]
        [-ProxyCredential <PSCredential>]
        [<CommonParameters>]
nickgw commented 1 year ago

Guessing it is the line Register-PSRepository -Default that fails? Could we add -Verbose -Debug to that command to see if we get more output? Could it be that we need to pass InstallationPolicy even though it is optional?

Syntax from the help:

Register-PSRepository
        [-Default]
        [-InstallationPolicy <String>]
        [-Proxy <Uri>]
        [-ProxyCredential <PSCredential>]
        [<CommonParameters>]

I can try that. I've taken the contents of psresourcerepository.config.ps1 and then the code that runs the tests in psresourcerepository.integration.tests.ps1 and it doesn't throw on my machine, which is why i'm confused.

johlju commented 1 year ago

Might be something that is different on the build worker. If we can't find it I will try set up an AppVeyor pipeline and see if we can get the same error there. It is possible to debug (with RDP, for 60 minutes per run) on those build workers.

johlju commented 1 year ago

Was busy at work so haven't been able to get back to this. Will setup AppVeyor tomorrow. It seems there is only one issue left with the integration test.

Looking at the verbose output it seems (for one thing) there is an issue with InstallationPolicy. If looking at the test PSResourceRepository_Remove_PSGallery at line 440:

https://dev.azure.com/dsccommunity/ComputerManagementDsc/_build/results?buildId=7028&view=logs&j=b097ec3e-ca2c-5821-744b-6fe27b54f344&t=27809048-cd5d-57e6-6d29-c11132922b99&l=440

VERBOSE: [WIN-UTBKALQA3RD]:                            [[PSResourceRepository]Integration_Test] NOTMATCH: Value (type 
'InstallationPolicy') for property 'InstallationPolicy' does not match. Current state is '' and desired state is 
'Untrusted'. (DRC0021)

In this section of the test it call Get-DscConfiguration to validate current state. What seems to hsappen here is that for some reason Compare() that is called by ResorceBase's Get() function seems to think the configuration contain InstallationPolicy = 'Untrusted' which it doesn't. This should not happen since the value for property InstallationPolicy should be $null if it is not specified in the configuration. So does this happen because the property is using the advanced type based on the enum InstallationPolicy, and that type is not nullable? If it is not possible to make the advanced typ nullable, will it be resolved if we change the property to use the string type and a validate set? See example: https://github.com/dsccommunity/SqlServerDsc/blob/main/source/Classes/002.DatabasePermission.ps1#L38-L41

johlju commented 1 year ago

Fixed AppVeyor (and minor tweaks): https://github.com/nickgw/ComputerManagementDsc/pull/2

nickgw commented 1 year ago

hey @johlju thanks for updating that! i'm having trouble finding the rdp output info, though!

johlju commented 1 year ago

Did you create your own free Account on AppVeyor as I mentioned in the PR description in your fork? I also added a comment to the PR here https://github.com/nickgw/ComputerManagementDsc/pull/2#issuecomment-1336398910

nickgw commented 1 year ago

Did you create your own free Account on AppVeyor as I mentioned in the PR description in your fork? I also added a comment to the PR here nickgw#2 (comment)

@johlju Thanks, I don't know how I missed the entirety of your PR's description this morning! I was able to get that working, and it also seems your theory about InstallationPolicy was correct. All Unit and Integration tests are finally passing now!

nickgw commented 1 year ago

Did you create your own free Account on AppVeyor as I mentioned in the PR description in your fork? I also added a comment to the PR here nickgw#2 (comment)

@johlju Thanks, I don't know how I missed the entirety of your PR's description this morning! I was able to get that working, and it also seems your theory about InstallationPolicy was correct. All Unit and Integration tests are finally passing now!

er spoke too soon... will try and investigate later today.

johlju commented 1 year ago

FYI the commit https://github.com/dsccommunity/ComputerManagementDsc/pull/395/commits/f71e6936acf51201332f26647598cd9c31f7fb51 will only change too 1.0.0.1 in the curremt session of the user (e.g. AppVeyor) running Pester tests, not the user (SYSTEM) that LCM runs under. Not sure what you intention was, but just looked strange so had to comment 🙂

nickgw commented 1 year ago

FYI the commit f71e693 will only change too 1.0.0.1 in the curremt session of the user (e.g. AppVeyor) running Pester tests, not the user (SYSTEM) that LCM runs under. Not sure what you intention was, but just looked strange so had to comment 🙂

Got it. So, in the appveyor run, I see the error I'm getting in the integration tests with PowerShellGet 2.2.5, but not 1.0.0.1. I dont see the same issue on my test machines so I'm not exactly sure where to go here.

I'm spinning up my own 2019 box to see if its a PSGet 2.2.5 & Server2019 issue now.

nickgw commented 1 year ago
PS C:\Windows\system32> Get-PSRepository | Unregister-PSRepository
PS C:\Windows\system32> Get-CimInstance win32_operatingsystem

SystemDirectory     Organization   BuildNumber RegisteredUser SerialNumber            Version
---------------     ------------   ----------- -------------- ------------            -------
C:\Windows\system32 gusztavvargadr 17763                      00431-10000-00000-AA740 10.0.17763

PS C:\Windows\system32> Get-Module packagemanagement

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.4.8.1    PackageManagement                   {Find-Package, Find-PackageProvider, Get-Package, Get-Pack...

PS C:\Windows\system32> Get-Module powershellget

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     2.2.5      PowerShellGet                       {Find-Command, Find-DscResource, Find-Module, Find-RoleCap...

PS C:\Windows\system32> Register-PSRepository -Default -Verbose
VERBOSE: Performing the operation "Register Module Repository." on target "Module Repository 'PSGallery' () in provider
 'PowerShellGet'.".
VERBOSE: Repository details, Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2'; IsTrusted =
'False'; IsRegistered = 'True'.

🤷🏼‍♂️ that's on a 2019 box I just span up with vagrant, so its something specific with the builders, i guess

johlju commented 1 year ago

Are you running that code as the user SYSTEM too?

nickgw commented 1 year ago

Are you running that code as the user SYSTEM too?

yup, same process as on the builders. I'm dropping psexec onto the system and launching powershell as SYSTEM.

johlju commented 1 year ago

Guessing we just remove the integration test for Default then and just keep the one that sets up another repository. 99% of users will probably do just that anyway 🤔 If there are any issues with Default (like we see on the build workers) then that can be solve (or not solved) in another PR.

nickgw commented 1 year ago

Guessing we just remove the integration test for Default then and just keep the one that sets up another repository. 99% of users will probably do just that anyway 🤔 If there are any issues with Default (like we see on the build workers) then that can be solve (or not solved) in another PR.

Agreed. Should I comment the tests out with the reason why we're not running them, or just remove them completely?

johlju commented 1 year ago

Should I comment the tests out with the reason why we're not running them, or just remove them completely?

I wonder if it is better to open an issue and move the code into the issue so it is being tracked and the code is saved, then we can emove the test code. What do you think? 🤔

nickgw commented 1 year ago

Should I comment the tests out with the reason why we're not running them, or just remove them completely?

I wonder if it is better to open an issue and move the code into the issue so it is being tracked and the code is saved, then we can emove the test code. What do you think? 🤔

https://github.com/dsccommunity/ComputerManagementDsc/issues/401

johlju commented 1 year ago

I gonna have a few busy days at work. But after friday I'm off work (vacation) for a month so will continue the review this weekend. 🙂

johlju commented 1 year ago

I will keep an eye on the build jobs and restart them if any fail due to unrelated issues to this PR. 🙂 Then I merge.

johlju commented 1 year ago

@nickgw awesome work on this! It is now merged. 🙂

nickgw commented 1 year ago

@johlju thanks so much! enjoy your vacation!!!