Skip to content

Instantly share code, notes, and snippets.

@Ioan-Popovici
Created October 23, 2018 15:46
Show Gist options
  • Save Ioan-Popovici/08821a75311bc706548d7661cfe61648 to your computer and use it in GitHub Desktop.
Save Ioan-Popovici/08821a75311bc706548d7661cfe61648 to your computer and use it in GitHub Desktop.
Gets registry key values for use in a CI as remediation script.
<#
.SYNOPSIS
Gets registry key values.
.DESCRIPTION
Gets registry key values for use in a CI as remediation script.
.NOTES
Created by
Ioan Popovici 2018-10-23
#>
[PSObject]$RegistryKeys = @(
@{
Path = 'HKLM:\SYSTEM\CurrentControlSet\Services\mrxsmb10'
Name = 'Start'
}
@{
Path = 'HKLM:\SYSTEM\CurrentControlSet\Services\LanmanWorkstation'
Name = 'DependOnService'
}
@{
Path = 'HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters'
Name = 'SMB1'
}
@{
Path = 'HKLM:\SYSTEM\CurrentControlSet\Control\Lsa'
Name = 'LmCompatibilityLevel'
}
)
[PSObject]$Result = @()
$RegistryKeys | ForEach-Object {
$Value = Get-ItemProperty -Path $_.Path -ErrorAction 'SilentlyContinue' | Select-Object -ExpandProperty $_.Name -ErrorAction 'SilentlyContinue'
If(-not $Value) { $value = 'N/A'}
[HashTable]$ResultProps = @{
#Path = $_.Path
Name = $_.Name
Value = ' = '+$Value
}
$Result += New-Object 'PSObject' -Property $ResultProps
}
[string]$Output = $($Result | Format-Table -Property Name, Value -HideTableHeaders | Out-String) -replace ('\s+\=\s+', ' = ')
Write-Output -InputObject $Output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment