Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add powershell help and log file #2

Merged
merged 3 commits into from
Sep 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 53 additions & 2 deletions sos-stig-compliant-domain-prep.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,45 @@
<#
.SYNOPSIS

Create a STIG complaint domain.

.DESCRIPTION

Import all the GPOs provided by SimeonOnSecurity to assist in making your
domain compliant with all applicable STIGs and SRGs.

Note: This script should work for most, if not all, systems without issue.
While @SimeonOnSecurity creates, reviews, and tests each repo intensivly,
we can not test every possible configuration nor does @SimeonOnSecurity
take any responsibility for breaking your system. If something goes wrong,
be prepared to submit an issue. Do not run this script if you don't
understand what it does.

.PARAMETER logFile

File name to log the output of certain operations to, in order to enable
easier troubleshooting in case something doesn't work as expected. The file
will be created within the path where the script is located.

.INPUTS

None. You cannot pipe objects into sos-stig-compliant-domain-prep.ps1.

.OUTPUTS

System.String. The script outputs messages of the process and what
operations it is performing.

.EXAMPLE

PS> .\sos-stig-compliant-domain-prep.ps1 -logFile 'YYYYmmdd_prep.log'

#>
[CmdletBinding()]
param (
[string]$logFile = 'domain_prep.log'
)

# Continue on error
$ErrorActionPreference = 'Continue'

Expand All @@ -12,6 +54,11 @@ do {
$scriptPath = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition
Set-Location $scriptPath

$logFilePath = Join-Path "$scriptPath" "$logFile"

$startTime = Get-Date -Format "yyyy-MM-ddTHH:mmK"
Add-Content -Path "$logFilePath" -Value "Start running script at: ${startTime}"

# Import PolicyDefinitions
$policyDefinitionsSource = Join-Path $scriptPath 'Files\PolicyDefinitions'
$policyDefinitionsDestination = 'C:\Windows\PolicyDefinitions'
Expand All @@ -30,7 +77,7 @@ try {
foreach ($sysvolPath in $sysvolPaths) {
$policyDefinitionsSysvolDestination = Join-Path $sysvolPath.FullName 'Policies\PolicyDefinitions'
if (!(Test-Path $policyDefinitionsSysvolDestination)) {
New-Item -Path $policyDefinitionsSysvolDestination -ItemType Directory -Force | Out-Null
New-Item -Path $policyDefinitionsSysvolDestination -ItemType Directory -Force | Out-File -FilePath "$logFilePath" -Append
}
Copy-Item -Path "$policyDefinitionsSource\*" -Destination $policyDefinitionsSysvolDestination -Force -Recurse
}
Expand All @@ -41,8 +88,9 @@ catch {

# Import GPOs into GPMC
function Import-GPOs {
[CmdletBinding()]
param (
[string]$gposDir
[Parameter(Mandatory=$true)][string]$gposDir
)

try {
Expand Down Expand Up @@ -89,3 +137,6 @@ function Import-GPOs {
# Import GPOs into GPMC
$gposDir = Join-Path $scriptPath 'Files\GPOs'
Import-GPOs -gposDir "$gposDir"

$endTime = Get-Date -Format "yyyy-MM-ddTHH:mmK"
Add-Content -Path "$logFilePath" -Value "Finish running script at: ${endTime}"
Loading