Skip to content

Instantly share code, notes, and snippets.

@fatherjack
Created October 1, 2019 15:27
Show Gist options
  • Save fatherjack/995a7bf6fc54d41794577260ff874a4d to your computer and use it in GitHub Desktop.
Save fatherjack/995a7bf6fc54d41794577260ff874a4d to your computer and use it in GitHub Desktop.
function Read-SQLConfigFile {
<#
.SYNOPSIS
Takes configuration file and shows features that are being set
.DESCRIPTION
Function to show what features and settings are being adjusted by the configuration file. Allows for comparison of
config files when combined with Compare-Object
.EXAMPLE
Read-SQLConfigFile -Path C:\temp\configuration.ini
explore all settings in specified configuration file
.EXAMPLE
get-childitem -filter *.ini | Read-SQLConfigFile
pass all ini files in current folder to Read-SQLConfigFile
.Example
$reference = get-item DPM_SQL_ConfigurationFile.ini | Read-SQLConfigFile
(get-item SP_SQL_ConfigurationFile.ini | Read-SQLConfigFile) | compare-object -ReferenceObject $reference
compare two configuration files to observe difference
.Notes
Author - Jonathan Allen
#>
[cmdletbinding()]
param(
[parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $true)][string]$Path,
[parameter()][string]$type
)
begin { }
process {
# get all rows that have = assignment
$content = select-string -Path $Path -Pattern "=" -AllMatches
return ($content | Select-Object line )
}
end { }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment