Skip to content

Commit 699d809

Browse files
committed
Remove redundant check and validation
1 parent a13082c commit 699d809

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

adapters/powershell/psDscAdapter/psDscAdapter.psm1

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,7 @@ function Invoke-DscOperation {
426426
# handle input objects by converting them to a hash table
427427
$validateProperty = $cachedDscResourceInfo.Properties | Where-Object -Property Name -EQ $_.Name
428428
if ($_.Value -is [System.Management.Automation.PSCustomObject]) {
429-
$validateProperty = $cachedDscResourceInfo.Properties | Where-Object -Property Name -EQ $_.Name
430-
if ($validateProperty -and $validateProperty.PropertyType -like "*PSCredential") {
429+
if ($validateProperty -and $validateProperty.PropertyType -in @('PSCredential', 'System.Management.Automation.PSCredential')) {
431430
if (-not $_.Value.Username -or -not $_.Value.Password) {
432431
"Credential object '$($_.Name)' requires both 'username' and 'password' properties" | Write-DscTrace -Operation Error
433432
exit 1
@@ -439,7 +438,7 @@ function Invoke-DscOperation {
439438
}
440439
}
441440
else {
442-
if ($validateProperty -and $validateProperty.PropertyType -like '*SecureString' -and -not [string]::IsNullOrEmpty($_.Value)) {
441+
if ($validateProperty -and $validateProperty.PropertyType -in @('SecureString', 'System.Security.SecureString') -and -not [string]::IsNullOrEmpty($_.Value)) {
443442
$dscResourceInstance.$($_.Name) = ConvertTo-SecureString -AsPlainText $_.Value -Force
444443
} else {
445444
$dscResourceInstance.$($_.Name) = $_.Value

0 commit comments

Comments
 (0)