Skip to content

Instantly share code, notes, and snippets.

@poojarsn
Created December 18, 2017 09:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save poojarsn/b80cbd9f597b72a3aa07c8ff2dc8f3f3 to your computer and use it in GitHub Desktop.
Save poojarsn/b80cbd9f597b72a3aa07c8ff2dc8f3f3 to your computer and use it in GitHub Desktop.
Powershell Read xml configuration
<?xml version="1.0" encoding="utf-8"?>
<InstallSettings>
<WebsiteRootPath>C:\inetpub\wwwroot\my\website</WebsiteRootPath>
</InstallSettings>
$ConfigPath = "C:\Software\Sitecore\SIMS\Script\InstallConfiguration.config"
#region Global Variable
$global:websiteRootPath ="";
#endregion
#region functions
function New-ConfigSettings([string] $configPath)
{
Write-Host "Started: Intialise and reading of configuration is in progress...";
[xml]$configXml = Get-Content ($configPath);
$global:websiteRootPath = $configXml.InstallSettings.WebsiteRootPath
Write-Host "End: Intialise and reading of configuration is completed successfully";
}
#endregion
New-ConfigSettings $ConfigPath
#read global variable
write-host $global:websiteRootPath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment