Skip to content

Commit 49c381c

Browse files
committed
Fix win_psDscAdapter for ClassBase resources PSCredentails fix convert to System.Management.Automation.PSCredential
1 parent 506ba9f commit 49c381c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

adapters/powershell/psDscAdapter/win_psDscAdapter.psm1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,11 @@ function Invoke-DscOperation {
427427
"Credential object '$($_.Name)' requires both 'username' and 'password' properties" | Write-DscTrace -Operation Error
428428
exit 1
429429
}
430-
$dscResourceInstance.$($_.Name) = [System.Management.Automation.PSCredential]::new($_.Value.Username, (ConvertTo-SecureString -AsPlainText $_.Value.Password -Force))
430+
431+
$username = $_.Value.secureObject.username
432+
$password = $_.Value.secureObject.password | ConvertTo-SecureString -AsPlainText -Force
433+
434+
$dscResourceInstance.$($_.Name) = [System.Management.Automation.PSCredential]::new($username, $password)
431435
} else {
432436
$dscResourceInstance.$($_.Name) = $_.Value.psobject.properties | ForEach-Object -Begin { $propertyHash = @{} } -Process { $propertyHash[$_.Name] = $_.Value } -End { $propertyHash }
433437
}

0 commit comments

Comments
 (0)