nsacyber / Windows-Secure-Host-Baseline

Configuration guidance for implementing the Windows 10 and Windows Server 2016 DoD Secure Host Baseline settings. #nsacyber
Other
1.56k stars 286 forks source link

Perhaps use Import-Module GroupPolicy.psm1 instead of dot-sourcing #6

Closed JasonFossen closed 7 years ago

JasonFossen commented 8 years ago

Hello IAD:

Currently, the instructions are to dot-source the GroupPolicy.ps1 script. Dot-sourcing still works, but it's not Microsoft's recommendation and people new to PowerShell don't like the syntax of using a single period as a command.

Suggestion: rename the extension of GroupPolicy.ps1 to GroupPolicy.psm1, then use the Import-Module cmdlet instead of dot-sourcing, like this:

Import-Module -Name .\Secure-Host-Baseline\Scripts\GroupPolicy.psm1

Using the Import-Module cmdlet like this has been supported since PowerShell 2.0.

In the long run, hopefully this whole SHB project will become a package in the PowerShell Gallery (www.powershellgallery.com) as a "proper" module in its own folder, etc., but the above change can be done immediately.

I've tested the above change on Server 2016 and there were no new error messages (the current errors related to ADMX/ADML files and GPO imports are already known).

Cheers, Jason

iadgovuser1 commented 7 years ago

Yeah, long term plans are to make a proper module. The change seems reasonable.