Almost in all the PowerShell Scripts, either we will be reading the configuration values from CSV File or an XML file. Let us Keep the code clean to read the value from the XML File.
function LoadConfigXML()
{
$Progress = "0:Entered"
Write-Host "Entered into LoadConfigXML Method" -ForegroundColor Yellow
Add-Content "$ProgressFile" "Entered into LoadConfigXML Method"
$ConfigXmlPath = $scriptBase + "Configuration.xml"
[Xml]$Config = Get-Content $ConfigXmlPath
Write-Host "Finished LoadConfigXML Method" -ForegroundColor Green
Add-Content "$ProgressFile" "Finished LoadConfigXML Method"
return $Config
$Progress = "0:Success"
}
From the main thread, we can call the below line.
# Load the Configuration File
$Config = LoadConfigXML
In the next article, let us see, how to segregate the PS1 files into small files and load them on the main file.
Happy Coding,
Sathish Nadarajan.
Leave a comment