Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Building mof file ignores any -ErrorAction SilentlyContinue in DSC Resources #35

Open
ThePSAdmin opened this issue Feb 8, 2018 · 0 comments
Assignees

Comments

@ThePSAdmin
Copy link

ThePSAdmin commented Feb 8, 2018

When converging in test-kitchen, it fails with the following error:

if (!$?) { if($LASTEXITCODE) { exit $LASTEXITCODE } else { exit 1 } } with id: 1DEA0CC5-2ABF-411C-A74A-BBA3FC0AD01A

D      [WinRM] creating command_id: 1DEA0CC5-2ABF-411C-A74A-BBA3FC0AD01A on shell_id 0B323920-4972-4FB8-90E4-949E4EC637C4
D      [WinRM] Waiting for output...
D      [WinRM] Processing output
       Get-ItemProperty : Cannot find path 'HKLM:\SOFTWARE\Microsoft\PowerShell\3\DSC' because it does not exist.
       At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psm1:607
       char:32
       + ...      $reg = Get-ItemProperty -path $key -name "PSDscAllowPlainTextPas ...
       +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           + CategoryInfo          : ObjectNotFound: (HKLM:\SOFTWARE\...owerShell\3\DSC:String) [Get-ItemProperty], ItemNotFo

After troubleshooting, I found that in this code block https://github.com/test-kitchen/kitchen-dsc/blob/master/lib/kitchen/provisioner/dsc.rb#L124

the mof file is built, but any errors that are ignored in the dsc resources causes kitchen-dsc to exit. In this case, its the following line from the build in PSDesiredStateConfiguration module:

$reg = Get-ItemProperty -path $key -name "PSDscAllowPlainTextPassword" -ea SilentlyContinue

I'm guessing the checking of the $error variable was put there for a reason, so I thought I'd check via this issue before opening a pull request. Otherwise a suggested fix is using -erroraction stop when compiling the mof and adding the exit code to the catch block.

@smurawski smurawski self-assigned this Mar 20, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants