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 = ' ' $eagleEyeSectionXmlString = '
' } 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