79 lines
3.6 KiB
PowerShell
79 lines
3.6 KiB
PowerShell
function Add-EagleEyeConfig{
|
|
<#
|
|
.SYNOPSIS
|
|
Adds the Eagle eye configuration to the machine config the local machine.
|
|
|
|
.DESCRIPTION
|
|
Gets the directory of the local machine config and uses System.Xml.XmlNode class
|
|
to add the configuration values for Eagle eye.
|
|
|
|
.PARAMETER use64bit
|
|
Boolean, passed to Get-DotNetConfigPath - if set to true, will return the filepath
|
|
of the 64 bit machine config file.
|
|
|
|
.EXAMPLE
|
|
Add-EagleEyeConfig
|
|
Base usage, will add the configuration group and section for eagle eye.
|
|
|
|
#>
|
|
[CmdletBinding()]
|
|
param(
|
|
[Parameter(Mandatory=$False)]
|
|
[bool]$use64Bit = $true
|
|
)
|
|
begin{
|
|
$logLead = (Get-LogLeadName);
|
|
|
|
Write-Verbose "$logLead Getting Maching.Config path, use64Bit set to $use64Bit"
|
|
$machineConfigPath = Get-DotNetConfigPath -use64Bit $use64Bit
|
|
if(!$machineConfigPath){throw "Machine config path could not be found"}
|
|
|
|
Write-Verbose "$logLead Reading machine config file located at $machineConfigPath"
|
|
$machineConfig = Read-XMLFile $machineConfigPath
|
|
if(!$machineConfig){throw "Machine config at $machineConfigPath could not be converted to xml"}
|
|
|
|
Write-Verbose "$logLead Initializing eagle eye configuration xml"
|
|
$eagleEyeConfigXmlString = '
|
|
<authorizedGroupsByOperation>
|
|
<add key="BustCache" value="CORP\Site Reliability Engineers" />
|
|
<add key="ElevateLogging" value="CORP\Site Reliability Engineers,CORP\SQL - Launch Team,CORP\Configuration,CORP\Support" />
|
|
<add key="ManipulateServiceInstance" value="CORP\Site Reliability Engineers" />
|
|
<add key="Install" value="CORP\Site Reliability Engineers" />
|
|
<add key="UploadFeature" value="CORP\Site Reliability Engineers" />
|
|
<add key="ConfigureTenant" value="CORP\Site Reliability Engineers" />
|
|
</authorizedGroupsByOperation>'
|
|
$eagleEyeSectionXmlString = '<section name="authorizedGroupsByOperation" type="System.Configuration.NameValueSectionHandler" />'
|
|
}
|
|
process{
|
|
|
|
Write-Verbose "$logLead Ensuring configuration and configSection nodes exist"
|
|
if(!$machineConfig.configuration){
|
|
[void]$machineConfig.AppendChild($machineConfig.CreateNode("element","configuration", $null))
|
|
}
|
|
if(!$machineConfig.configuration.configSections){
|
|
[void]$machineConfig.SelectSingleNode("configuration").AppendChild($machineConfig.CreateElement("configSections"))
|
|
}
|
|
|
|
Write-Verbose "$logLead Adding eagle eye config to configuration node."
|
|
if(!$machineConfig.configuration.authorizedGroupsByOperation){
|
|
$eagleEyConfigDoc = [xml]($eagleEyeConfigXmlString)
|
|
$eagleEyeNode = $machineConfig.ImportNode($eagleEyConfigDoc.FirstChild, $true)
|
|
[void]$machineConfig.configuration.AppendChild($eagleEyeNode)
|
|
}
|
|
Write-Verbose "$logLead Adding eagle eye section group to configSections"
|
|
if(!($machineConfig.configuration.configSections.section | Where-Object {$_.Name -eq "authorizedGroupsByOperation"})){
|
|
$eagleEyeSection = [xml]($eagleEyeSectionXmlString)
|
|
$eagleEyeSectionNode = $machineConfig.ImportNode($eagleEyeSection.FirstChild, $true)
|
|
[void]$machineConfig.configuration.SelectSingleNode("configSections").AppendChild($eagleEyeSectionNode)
|
|
}
|
|
|
|
Write-Verbose "$logLead Saving config file to path $machineConfigPath"
|
|
$machineConfig.Save($machineConfigPath)
|
|
|
|
Write-Verbose "$logLead Finished"
|
|
}
|
|
}
|
|
# ToDo - Either move these to common if they add value or modify the manifest to not export them
|
|
#region Private functions
|
|
|