Skip to content

Commit a4b4a86

Browse files
committed
Test PowerShell
1 parent d46f132 commit a4b4a86

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

powershell-adapter/Tests/win_powershellgroup.tests.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ resources:
224224
UserName: 'User'
225225
OtherProperty: 'Password'
226226
"@
227-
$out = dsc config get -i $yaml 2>&1 | Out-String
227+
$out = dsc -l trace config get -i $yaml 2>&1 | Out-String
228+
$out = dsc -l trace config get -i $yaml 2>&1 | Out-String
228229
$LASTEXITCODE | Should -Be 2
229230
$out | Should -Not -BeNullOrEmpty
230231
$out | Should -BeLike "*ERROR*The PSCredential property 'Credential' is missing required fields*"

powershell-adapter/psDscAdapter/psDscAdapter.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ function Invoke-DscOperation {
426426
$validateProperty = $cachedDscResourceInfo.Properties | Where-Object -Property Name -EQ $_.Name
427427
if ($validateProperty.PropertyType -eq 'PSCredential') {
428428
if (-not $_.Value.Username -or -not $_.Value.Password) {
429-
"The PSCredential property '$($_.Name)' is missing required fields 'Username' and 'Password'" | Write-DscTrace -Operation Error
429+
"Credential object '$($_.Name)' requires both 'username' and 'password' properties" | Write-DscTrace -Operation Error
430430
exit 1
431431
}
432432
$dscResourceInstance.$($_.Name) = [System.Management.Automation.PSCredential]::new($_.Value.Username, (ConvertTo-SecureString -AsPlainText $_.Value.Password -Force))

powershell-adapter/psDscAdapter/win_psDscAdapter.psm1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ function Invoke-DscOperation {
368368
$validateProperty | Write-DscTrace -Operation Debug
369369
if ($validateProperty.PropertyType -eq '[PSCredential]') {
370370
if (-not $_.Value.Username -or -not $_.Value.Password) {
371-
"The PSCredential property '$($_.Name)' is missing required fields 'Username' and 'Password'" | Write-DscTrace -Operation Error
371+
"Credential object '$($_.Name)' requires both 'username' and 'password' properties" | Write-DscTrace -Operation Error
372372
exit 1
373373
}
374374
$property.$($_.Name) = [System.Management.Automation.PSCredential]::new($_.Value.Username, (ConvertTo-SecureString -AsPlainText $_.Value.Password -Force))
@@ -418,7 +418,7 @@ function Invoke-DscOperation {
418418
$validateProperty = $cachedDscResourceInfo.Properties | Where-Object -Property Name -EQ $_.Name
419419
if ($validateProperty.PropertyType -eq '[PSCredential]') {
420420
if (-not $_.Value.Username -or -not $_.Value.Password) {
421-
"The PSCredential property '$($_.Name)' is missing required fields 'Username' and 'Password'" | Write-DscTrace -Operation Error
421+
"Credential object '$($_.Name)' requires both 'username' and 'password' properties" | Write-DscTrace -Operation Error
422422
exit 1
423423
}
424424
$dscResourceInstance.$($_.Name) = [System.Management.Automation.PSCredential]::new($_.Value.Username, (ConvertTo-SecureString -AsPlainText $_.Value.Password -Force))
@@ -476,7 +476,7 @@ function Invoke-DscOperation {
476476
$validateProperty = $cachedDscResourceInfo.Properties | Where-Object -Property Name -EQ $_.Name
477477
if ($validateProperty.PropertyType -eq '[PSCredential]') {
478478
if (-not $_.Value.Username -or -not $_.Value.Password) {
479-
"The PSCredential property '$($_.Name)' is missing required fields 'Username' and 'Password'" | Write-DscTrace -Operation Error
479+
"Credential object '$($_.Name)' requires both 'username' and 'password' properties" | Write-DscTrace -Operation Error
480480
exit 1
481481
}
482482
$property.$($_.Name) = [System.Management.Automation.PSCredential]::new($_.Value.Username, (ConvertTo-SecureString -AsPlainText $_.Value.Password -Force))

0 commit comments

Comments
 (0)