|
|
|
@ -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
|
|
|
|
|