Command/TFS/GetLatestByChangeset.ps1
<##############################################################
Gets the server changes of the input changeset from the TFS server. ###############################################################> Import-Module CmxModule -Force SetWindowTitle $MyInvocation.MyCommand.Name Write-Output "This script runs a [tf get] command regarding the given changeset." $workspace = $LocalWorkspace $changeset = Read-Host "Please enter the changeset" Write-Output "Changeset: $changeset" Write-Output "Workspace: $workspace" Write-Output "Run preview . . . " $result = PreviewGetLatestByVersion -RootDir $workspace -ItemVersion $changeset Write-Output "Run preview has finished" if($result.ExitCode -ne 0) { $previewResultString = "The preview detected issues, so the real command is not executed. " $previewResultString += "Please fix these issues first, then try again." Write-Output "PreviewResultString: $previewResultString" Write-Output "" Write-Output "ExitCode: $($result.ExitCode)" Write-Output "" Write-Output "Issues: " Write-Output "$($result.StandardError)" } else { # Show the standard output in detail (if it is small) or just the linecount (if it is big). $measureResult = $result.StandardOutput | Measure-Object -Line $standardOutputLineCount = $measureResult.Lines Write-Output "StandardOutput: " if($standardOutputLineCount -gt 20) { Write-Output "Contains $standardOutputLineCount lines" } else { Write-Output "$($result.StandardOutput)" } Write-Output "Run command . . . " $realResult = GetLatestByVersion -RootDir $workspace -ItemVersion $changeset Write-Output "Run command has finished" if($realResult.ExitCode -ne 0) { $realResultString = "The command did not succeed. Please see the issues." Write-Output "RealResultString: $realResultString" Write-Output "" Write-Output "ExitCode: $($realResult.ExitCode)" Write-Output "" Write-Output "Issues: " Write-Output "$($realResult.StandardError)" } else { $realResultString = "The command succeed." Write-Output "RealResultString: $realResultString" Write-Output "" Write-Output "ExitCode: $($realResult.ExitCode)" Write-Output "Issues: " Write-Output "$($realResult.StandardError)" # Show the standard output in detail (if it is small) or just the linecount (if it is big). $measureResult = $realResult.StandardOutput | Measure-Object -Line $standardOutputLineCount = $measureResult.Lines Write-Output "StandardOutput: " if($standardOutputLineCount -gt 20) { Write-Output "Contains $standardOutputLineCount lines" } else { Write-Output "$($realResult.StandardOutput)" } } } Read-Host "The script has finished. Press any key to exit" |