Additions/Get-AdditionVersionInBranch.ps1
function Get-AdditionVersionInBranch { Param( [Parameter(Mandatory=$true)] [string]$BranchPath, [Parameter(Mandatory=$true)] [string]$AdditionBranchPath ) $TempDirectory = Create-TempDirectory [string]$MaxAdditionVersion = '' [string]$DeltaVersionPrefix = '' [int]$ObjectNo = 0 [string]$Activity = 'Retrieving Addition Version {0} for {1}' -f $AdditionBranchPath, $BranchPath Write-Progress -Activity $Activity if ($AdditionBranchPath.Substring(0,1) -eq '$') { Get-ObjectsFromTFSBranch -BranchPath $AdditionBranchPath -DestinationPath $TempDirectory -Type Folder $AdditionObjects = Get-ChildItem $TempDirectory -File } else { $AdditionObjects = Get-ChildItem $AdditionBranchPath -File } $TempDirectory2 = Create-TempDirectory foreach($AdditionObject in $AdditionObjects) { $ObjectNo += 1 Write-Progress -Activity $Activity -PercentComplete (($ObjectNo / $AdditionObjects.count) * 100) if (!(Get-IsStandardNAVObject -ObjectFileName $AdditionObject.Name)) { $ObjectName = $AdditionObject.Name.Substring(0,$AdditionObject.Name.LastIndexOf('.')) + ".TXT" $BranchObjectPath = Join-Path -Path $BranchPath -ChildPath $ObjectName $LocalObjectPath = (Join-Path $TempDirectory2 $ObjectName) if ($BranchObjectPath.Substring(0,1) -eq '$') { $BranchObject = Get-ObjectsFromTFSBranch -BranchPath $BranchObjectPath -DestinationPath $LocalObjectPath -Type File } else { if ([IO.File]::Exists($BranchObjectPath)) { [IO.File]::Copy($BranchObjectPath,$LocalObjectPath) } } if([IO.File]::Exists($LocalObjectPath)) { if ($DeltaVersionPrefix -eq '') { $DeltaVersionPrefix = Get-DeltaVersionPrefix -ObjectFileName $LocalObjectPath } $AdditionVersion = Get-NAVObjectVersion -ObjectFilePath $LocalObjectPath -VersionPrefix $DeltaVersionPrefix if ($AdditionVersion -gt $MaxAdditionVersion) { $MaxAdditionVersion = $AdditionVersion } } } } Remove-Item -Path $TempDirectory -Recurse Remove-Item -Path $TempDirectory2 -Recurse Write-Progress -Activity $Activity -Completed $MaxAdditionVersion } function Get-DeltaVersionPrefix { Param( [Parameter(Mandatory=$true)] [string]$ObjectFileName ) $CustomObjectVersion = Get-NAVCustomObjectVersion -ObjectFilePath $ObjectFileName $RegexMatch = [Regex]::Match($CustomObjectVersion,'\d') if ($RegexMatch.Success) { $CustomObjectVersion.Substring(0,$RegexMatch.Index) } } Export-ModuleMember -Function Get-AdditionVersionInBranch |