mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
win_dsc - return warning from DSC invocation (#51927)
This commit is contained in:
parent
338ad565a7
commit
179cbb9891
4 changed files with 16 additions and 2 deletions
|
@ -236,7 +236,11 @@ try
|
|||
{
|
||||
#Defined variables in strictmode
|
||||
$TestError, $TestError = $null
|
||||
$TestResult = Invoke-DscResource @Config -Method Test -ModuleName $Module -ErrorVariable TestError -ErrorAction SilentlyContinue
|
||||
$TestResult = Invoke-DscResource @Config -Method Test -ModuleName $Module -ErrorVariable TestError -ErrorAction SilentlyContinue -WarningVariable TestWarn
|
||||
foreach ($warning in $TestWarn) {
|
||||
Add-Warning -obj $result -message $warning.Message
|
||||
}
|
||||
|
||||
if ($TestError)
|
||||
{
|
||||
throw ($TestError[0].Exception.Message)
|
||||
|
@ -245,7 +249,10 @@ try
|
|||
{
|
||||
if ($check_mode -eq $False)
|
||||
{
|
||||
$SetResult = Invoke-DscResource -Method Set @Config -ModuleName $Module -ErrorVariable SetError -ErrorAction SilentlyContinue -WarningAction SilentlyContinue
|
||||
$SetResult = Invoke-DscResource -Method Set @Config -ModuleName $Module -ErrorVariable SetError -ErrorAction SilentlyContinue -WarningVariable SetWarn
|
||||
foreach ($warning in $SetWarn) {
|
||||
Add-Warning -obj $result -message $warning.Message
|
||||
}
|
||||
if ($SetError -and ($SetResult -eq $null))
|
||||
{
|
||||
#If SetError was filled, throw to exit out of the try/catch loop
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue