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

%3CLINGO-SUB%20id%3D%22lingo-sub-1951221%22%20slang%3D%22en-US%22%3EBaseline%20throws%20a%20silent%20error.%20Suggestion%20for%20a%20quick%20fix%20in%20BaselineLocalInstall.ps1%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1951221%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ethe%20BaselineLocalInstall.ps1%20in%20SCT%201.0%20for%20Server%202019%20throws%20a%20silent%20error%20under%20certain%20circumstances%20that%20is%20added%20to%20the%20error%20variable.%20Responsible%20is%20line%20147%3A%3C%2FP%3E%3CDIV%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%3CP%3E%3CSTRONG%3E%3CSPAN%3Eif%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B(%3C%2FSPAN%3E%3CSPAN%3E%24null%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B-eq%26nbsp%3B(%3C%2FSPAN%3E%3CSPAN%3EGet-Command%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3ELGPO.exe%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B-ErrorAction%26nbsp%3BSilentlyContinue))%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EWhen%20the%20script%20runs%20successful%2C%20this%20is%20the%20only%20error%20in%20%24Error.%20Since%20%24Error%20is%20currently%20the%20only%20way%20to%20check%20whether%20the%20baseline%20script%20ran%20successful%20or%20not%2C%20this%20causes%20an%20issue.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EThe%20fix%20is%20simple%2C%20however.%20Please%20replace%20the%20error%20action%20with%20%3CSTRONG%3EIgnore%3C%2FSTRONG%3E.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3E%3CSTRONG%3Eif%26nbsp%3B(%24null%26nbsp%3B-eq%26nbsp%3B(Get-Command%26nbsp%3BLGPO.exe%26nbsp%3B-ErrorAction%26nbsp%3BIgnore))%3C%2FSTRONG%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EThis%20acts%20like%20SilentlyContinue%20but%20does%20not%20add%20the%20error%20to%20the%20%24Error%20variable%2C%20and%20if%20the%20script%20ran%20successful%20%24Error%20will%20be%20empty.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1951238%22%20slang%3D%22en-US%22%3ERe%3A%20Baseline%20throws%20a%20silent%20error.%20Suggestion%20for%20a%20quick%20fix%20in%20BaselineLocalInstall.ps1%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1951238%22%20slang%3D%22en-US%22%3E%3CP%3EAlso%20pinging%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F272514%22%20target%3D%22_blank%22%3E%40Rick_Munck%3C%2FA%3E%26nbsp%3B%20for%20that%20to%20see.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1953728%22%20slang%3D%22en-US%22%3ERe%3A%20Baseline%20throws%20a%20silent%20error.%20Suggestion%20for%20a%20quick%20fix%20in%20BaselineLocalInstall.ps1%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1953728%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F65328%22%20target%3D%22_blank%22%3E%40Daniel%20Niccoli%3C%2FA%3E%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F272514%22%20target%3D%22_blank%22%3E%40Rick_Munck%3C%2FA%3E%26nbsp%3B-%20that%20change%20makes%20sense%20to%20me.%20Good%20idea%20-%20thanks.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1956080%22%20slang%3D%22en-US%22%3ERe%3A%20Baseline%20throws%20a%20silent%20error.%20Suggestion%20for%20a%20quick%20fix%20in%20BaselineLocalInstall.ps1%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1956080%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F65328%22%20target%3D%22_blank%22%3E%40Daniel%20Niccoli%3C%2FA%3E%26nbsp%3Bwe%20greatly%20appreciate%20the%20suggestion%20and%20will%20make%20the%20change%20in%20the%20Final%2020H2%20package%20we%20are%20planning%20to%20release%20towards%20the%20middle%20of%20the%20month!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2382949%22%20slang%3D%22en-US%22%3ERe%3A%20Baseline%20throws%20a%20silent%20error.%20Suggestion%20for%20a%20quick%20fix%20in%20BaselineLocalInstall.ps1%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2382949%22%20slang%3D%22en-US%22%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F272514%22%20target%3D%22_blank%22%3E%40Rick_Munck%3C%2FA%3E%2C%20it%20would%20be%20great%20if%20you%20could%20backport%20the%20fix%20to%20the%20Server%202019%20baseline.%3C%2FLINGO-BODY%3E
Regular Contributor

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

@Daniel Niccoli @Rick_Munck - that change makes sense to me. Good idea - thanks.

@Daniel Niccoli we greatly appreciate the suggestion and will make the change in the Final 20H2 package we are planning to release towards the middle of the month!

Hi @Rick_Munck, it would be great if you could backport the fix to the Server 2019 baseline.

@Daniel Niccoli it should have been included in the 20H2 package for client and server.  Are you seeing something to the contrary?

 

@Rick_Munck The SCT 1.0 contains a Server 2019 package with files that have not been modified since 2018. The server 20H2 package in that SCT 1.0 has modified files and I do see the changes there. But we use Server 2019 (LTSC) and not Server 20H2.

Side question: What does the version number stand for? I see packages being added, but the version number doesn't change.

@Daniel Niccoli unfortunately we don't have the cycles to go back and update old baselines.  Our recommendations/ fixes are always reflected in the latest version.  You can take the script out of the newest and use with your version, shouldn't be an issue.

 

As for version number, that is a required field that has to be there, technically LGPO and every other download should be it's own DL and version but we decided it was best to use a master name for the download and keep everything in one spot for ease.

@Rick_Munck Old? Server 2019 is still in Mainstream support until the second half of 2024. :thinking_face: Do you test the 20H2 baselines against Server 2019? Because if you do, then I trust that they work and don't break anything. The baseline does change some quite delicate settings.

Security baselines only get one pass per release, we do not go back and revisit previous releases. Our recommendations build upon older baselines and are updated to reflect new and updated guidance. In the case of 2019 (LTSC) I suggest you use Policy Analyzer and compare the initial release versus the current and make an informed decision
:( okay.

So, for "Windows 10 Version 1909 and Windows Server Version 1909 Security Baseline" I find the following Analyzer rulesets in the documentation folder:

MSFT-WS2019-DomainController-FINAL.PolicyRules
MSFT-WS2019-MemberServer-FINAL.PolicyRules

For the "Windows-10-Windows Server-v20H2-Security-Baseline-FINAL" I only find

MSFT-Win10-WS-v20H2-FINAL.PolicyRules

Was that forgotten or was it decided that there will be no more server policyrules included?
We used to provide separate PolicyRule files but as we thought more about it and spoke with customers, it became clear one was okay since the filter in Policy Analyzer can achieve the same result.
www.000webhost.com