@@ -365,9 +365,10 @@ function Invoke-DscOperation {
365365 $DesiredState.properties.psobject.properties | ForEach-Object - Begin { $property = @ {} } - Process {
366366 if ($_.Value -is [System.Management.Automation.PSCustomObject ]) {
367367 $validateProperty = $cachedDscResourceInfo.Properties | Where-Object - Property Name -EQ $_.Name
368- if ($validateProperty.PropertyType -eq ' PSCredential' ) {
369- if (-not $_.Value.Username -and -not $_.Value.Password ) {
370- " Credential property '$ ( $_.Name ) ' requires both username and password input object" | Write-DscTrace - Operation Error
368+ $validateProperty | Write-DscTrace - Operation Debug
369+ if ($validateProperty.PropertyType -eq ' [PSCredential]' ) {
370+ if (-not $_.Value.Username -or -not $_.Value.Password ) {
371+ " The PSCredential property '$ ( $_.Name ) ' is missing required fields 'Username' and 'Password'" | Write-DscTrace - Operation Error
371372 exit 1
372373 }
373374 $property .$ ($_.Name ) = [System.Management.Automation.PSCredential ]::new($_.Value.Username , (ConvertTo-SecureString - AsPlainText $_.Value.Password - Force))
@@ -415,9 +416,9 @@ function Invoke-DscOperation {
415416 # handle input objects by converting them to a hash table
416417 if ($_.Value -is [System.Management.Automation.PSCustomObject ]) {
417418 $validateProperty = $cachedDscResourceInfo.Properties | Where-Object - Property Name -EQ $_.Name
418- if ($validateProperty.PropertyType -eq ' PSCredential' ) {
419- if (-not $_.Value.Username -and -not $_.Value.Password ) {
420- " Credential property '$ ( $_.Name ) ' requires both username and password input object " | Write-DscTrace - Operation Error
419+ if ($validateProperty.PropertyType -eq ' [ PSCredential] ' ) {
420+ if (-not $_.Value.Username -or -not $_.Value.Password ) {
421+ " The PSCredential property '$ ( $_.Name ) ' is missing required fields 'Username' and 'Password' " | Write-DscTrace - Operation Error
421422 exit 1
422423 }
423424 $dscResourceInstance .$ ($_.Name ) = [System.Management.Automation.PSCredential ]::new($_.Value.Username , (ConvertTo-SecureString - AsPlainText $_.Value.Password - Force))
@@ -473,9 +474,9 @@ function Invoke-DscOperation {
473474 $DesiredState.properties.psobject.properties | ForEach-Object - Begin { $property = @ {} } - Process {
474475 if ($_.Value -is [System.Management.Automation.PSCustomObject ]) {
475476 $validateProperty = $cachedDscResourceInfo.Properties | Where-Object - Property Name -EQ $_.Name
476- if ($validateProperty.PropertyType -eq ' PSCredential' ) {
477- if (-not $_.Value.Username -and -not $_.Value.Password ) {
478- " Credential property '$ ( $_.Name ) ' requires both username and password input object " | Write-DscTrace - Operation Error
477+ if ($validateProperty.PropertyType -eq ' [ PSCredential] ' ) {
478+ if (-not $_.Value.Username -or -not $_.Value.Password ) {
479+ " The PSCredential property '$ ( $_.Name ) ' is missing required fields 'Username' and 'Password' " | Write-DscTrace - Operation Error
479480 exit 1
480481 }
481482 $property .$ ($_.Name ) = [System.Management.Automation.PSCredential ]::new($_.Value.Username , (ConvertTo-SecureString - AsPlainText $_.Value.Password - Force))
0 commit comments