Skip to content

Commit 832d411

Browse files
author
Steve Lee (POWERSHELL HE/HIM) (from Dev Box)
committed
add warning if using winps and module not found
1 parent 2e10128 commit 832d411

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

powershell-adapter/psDscAdapter/win_psDscAdapter.psm1

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ function Invoke-DscOperation {
373373

374374
# using the cmdlet the appropriate dsc module, and handle errors
375375
try {
376-
Write-DscTrace -Operation Debug -Message "Module: $($cachedDscResourceInfo.ModuleName), Name: $($cachedDscResourceInfo.Name), Property: $($property)"
376+
Write-DscTrace -Operation Debug -Message "Module: $($cachedDscResourceInfo.ModuleName), Name: $($cachedDscResourceInfo.Name), Property: `n$($property | Out-String)"
377377
$invokeResult = Invoke-DscResource -Method $Operation -ModuleName $cachedDscResourceInfo.ModuleName -Name $cachedDscResourceInfo.Name -Property $property -ErrorAction Stop
378378

379379
if ($invokeResult.GetType().Name -eq 'Hashtable') {
@@ -389,6 +389,9 @@ function Invoke-DscOperation {
389389
}
390390
catch {
391391
$_.Exception | Format-List * -Force | Out-String | Write-DscTrace -Operation Debug
392+
if ($_.Exception.MessageId -eq 'DscResourceNotFound') {
393+
Write-DscTrace -Operation Warn -Message 'For Windows PowerShell, DSC resources must be installed with scope AllUsers'
394+
}
392395
'Exception: ' + $_.Exception.Message | Write-DscTrace -Operation Error
393396
exit 1
394397
}
@@ -427,7 +430,10 @@ function Invoke-DscOperation {
427430
}
428431
}
429432
catch {
430-
433+
$_.Exception | Format-List * -Force | Out-String | Write-DscTrace -Operation Debug
434+
if ($_.Exception.MessageId -eq 'DscResourceNotFound') {
435+
Write-DscTrace -Operation Warn -Message 'For Windows PowerShell, DSC resources must be installed with scope AllUsers'
436+
}
431437
'Exception: ' + $_.Exception.Message | Write-DscTrace -Operation Error
432438
exit 1
433439
}

0 commit comments

Comments
 (0)