Forum Discussion

DanielNiccoli's avatar
DanielNiccoli
Iron Contributor
Dec 03, 2020

Baseline throws a silent error. Suggestion for a quick fix in BaselineLocalInstall.ps1

Hi,

 

the BaselineLocalInstall.ps1 in SCT 1.0 for Server 2019 throws a silent error under certain circumstances that is added to the error variable. Responsible is line 147:

 

if ($null -eq (Get-Command LGPO.exe -ErrorAction SilentlyContinue))

 

When the script runs successful, this is the only error in $Error. Since $Error is currently the only way to check whether the baseline script ran successful or not, this causes an issue.

 

The fix is simple, however. Please replace the error action with Ignore.

 

if ($null -eq (Get-Command LGPO.exe -ErrorAction Ignore))

 

This acts like SilentlyContinue but does not add the error to the $Error variable, and if the script ran successful $Error will be empty.

 

11 Replies

Resources