Skip to content

Conversation

@mimachniak
Copy link

PR Summary

  • I change creating object System.Management.Automation.PSCredential for ScriptBase resources base on Get-Credential parameters
  • Added dsc.yaml test file for ScriptBased DSC

PR Context

Fix using ScriptBased DSC resources when is reguired to use parameters with Get-Credentials

@mimachniak
Copy link
Author

@microsoft-github-policy-service agree

@mimachniak please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree

@Gijsreyn
Copy link
Contributor

@mimachniak - as I have already spoken with you on socials, is this perhaps also possible for class-based DSC resources (both in the 5.1 and 7.0 adapter)? Can you also include a testcase that covers this change?

@mimachniak
Copy link
Author

Yes I working o it

mimachniak and others added 3 commits December 17, 2025 16:26
…rt to System.Management.Automation.PSCredentia - code optimalization remove unused function
@mimachniak mimachniak changed the title Win ps dsc adapter ps credentials fix script dsc win_psDscAdapter and psDscAdapter PScredentials fix for passing username and password Dec 18, 2025
…t to System.Management.Automation.PSCredential
…t to System.Management.Automation.PSCredential - if change to recognize user information
@mimachniak
Copy link
Author

@Gijsreyn , @SteveL-MSFT - I added in test folder yaml's that are using TestClass for validation using PSCredentials, I tested on version 5.1 and 7 of PowerShell

@Gijsreyn
Copy link
Contributor

@mimachniak - can it be tested inside the powershellgroup.config.tests.ps1 and win_powershellgroup.tests.ps1 or is it already covered?

@mimachniak
Copy link
Author

@mimachniak - can it be tested inside the powershellgroup.config.tests.ps1 and win_powershellgroup.tests.ps1 or is it already covered?

I will add today, I added yaml files for running test

@mimachniak
Copy link
Author

mimachniak commented Dec 21, 2025

@mimachniak - can it be tested inside the powershellgroup.config.tests.ps1 and win_powershellgroup.tests.ps1 or is it already covered?

I added unit test and validation in file in powershellgroup.config.tests.ps1

@mimachniak
Copy link
Author

I added test for 5.1 as well

@SteveL-MSFT
Copy link
Member

@mimachniak Thanks for adding the test resource, but there isn't a Pester test using it yet?

@mimachniak
Copy link
Author

mimachniak commented Jan 12, 2026

@SteveL-MSFT I will add test today

@mimachniak
Copy link
Author

@SteveL-MSFT I will add test today

Test added and minor fix to adapter as well

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

$_.Value.Password

if (-not $hasSecureCred -and -not $hasTextCred) {
"$($_.Value)" | Write-DscTrace -Operation Warn
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The debug log statement here appears to be logging the entire credential object value, which could potentially expose sensitive information like passwords in debug logs. Consider logging only non-sensitive metadata about the credential (like its type or name) rather than the full value.

Copilot uses AI. Check for mistakes.
$_.Value.Password

if (-not $hasSecureCred -and -not $hasTextCred) {
"$($_.Value)" | Write-DscTrace -Operation Warn
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The debug log statement here appears to be logging the entire credential object value, which could potentially expose sensitive information like passwords in debug logs. Consider logging only non-sensitive metadata about the credential (like its type or name) rather than the full value.

Suggested change
"$($_.Value)" | Write-DscTrace -Operation Warn
"Invalid credential object for property '$($_.Name)'" | Write-DscTrace -Operation Warn

Copilot uses AI. Check for mistakes.
[System.Management.Automation.PSCredential]::new($username, $password)
}


Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is trailing whitespace on this line. This should be removed to maintain code cleanliness.

Suggested change

Copilot uses AI. Check for mistakes.
@mimachniak
Copy link
Author

mimachniak commented Jan 14, 2026

@SteveL-MSFT I see that I need to add to test in script base module creation, I will do it today

@SteveL-MSFT
Copy link
Member

@mimachniak Some Windows Pester tests failed in CI, can you take a look at those? Also look over the Copilot feedback and see if any should be addressed. Thanks!

@mimachniak
Copy link
Author

@mimachniak Some Windows Pester tests failed in CI, can you take a look at those? Also look over the Copilot feedback and see if any should be addressed. Thanks!

Yes I'm fixing this as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants