If you are using PowerGUI (which you should) and some of your collaegues do too, you might want to use a central configuration. Whenever you want to update the central configuration xml file, you need to increment the version number in order to push this change out to your collaegues. The following function increments the version number for you and even allows you to store the new file to the central location at the same time. All without having to edit the complex xml file manually. It even saves a backup copy of your central config file in case you mess up
It assumes you use a simple x.y version number, so please start out with 2.0 when setting up your config.
To update your central config: just make the modifications within PowerGUI and then run this function.
Function Increment-PowerGuiXmlVersion { Param( $PersonalXmlFile = (Join-Path $env:appdata "Quest Software\PowerGUI\config.xml"), $CentralXmlFile = 'P:\Centrally Managed Files\config.xml', $XPath = "//container[@name='version']", $IncrementMajor = $false, $IncrementMinor = $true ) # Load central xml file (for backup and reading the current version number) $CentralConfig = New-Object System.Xml.XmlDocument $CentralConfig.Load($CentralXmlFile) # Select the correct node $NodeToRead = $CentralConfig.SelectSingleNode($XPath) # Read the current version $CurrentVersion = $NodeToRead.Value $MajorVersion = [Int]($CurrentVersion.Split(".")[0]) $MinorVersion = [Int]($CurrentVersion.Split(".")[1]) Write-Host "Current Version of Central Xml File: $CurrentVersion" # Backup central xml file $BackupFileName = $CentralXmlFile.Replace(".xml", ("_{0}.xml" -f $CurrentVersion)) $CentralConfig.Save($BackupFileName) # Load personal xml file $PersonalConfig = New-Object System.Xml.XmlDocument $PersonalConfig.Load($PersonalXmlFile) # Select the correct node $NodeToBeChanged = $PersonalConfig.SelectSingleNode($XPath) # Increment the version If ($IncrementMinor){$MinorVersion++} If ($IncrementMajor){$MajorVersion++; $MinorVersion = 0} $newVersion = [string]::Concat($MajorVersion,".",$MinorVersion) Write-Host "New Version of Central Xml File: $newVersion" # Write the new version $NodeToBeChanged.Value = $newVersion # Save the personal xml file as the new central xml file $PersonalConfig.Save($CentralXmlFile) } |
One Response to Increment PowerGUI Xml Version with Powershell
Tags
Active Directory API bind order cleanup cluster CPU Custom Fields datastores description device management directory tree errors Event Log file name filter Fun function HA IT known issues License Server LUN multipath NIC objects Oneliner portgroups PowerCLI PowerShell profile recursive Registry Scripts security session share snapshots SQL Stat VI Toolkit VMware vSphere WMI WSUS ZenArchives
- July 2012
- July 2011
- February 2011
- January 2011
- December 2010
- May 2010
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008





Any sample for increment xml version if file is in TFS . Checkout, modify xml and checkin.