Forum Discussion
amitaiemd
Jul 13, 2023Copper Contributor
How to upload a file to a folder present in TFVC repo from an Azure pipelines.yml file
Hi Team, Can you please help me with powershell rest API, to upload a file to a folder in TFVC(TFS) repo from an Azure pipelines.yml file . Thanks
Kidd_Ip
Sep 07, 2025MVP
Below the step by step:
- Prepare Your YAML Pipeline
trigger:
- main
pool:
vmImage: 'windows-latest'
steps:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
# Set working directory
cd "$(Build.SourcesDirectory)"
# Create a sample file
echo "Hello from pipeline" > newfile.txt
# Add the file to TFVC
tf add newfile.txt
# Check in the file
tf checkin newfile.txt /comment:"Added via pipeline" /recursive /force /loginType:OAuth /login:.,$env:SYSTEM_ACCESSTOKEN
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
- Important Configuration Notes
- Make sure “Allow scripts to access OAuth token” is enabled in your pipeline settings.
- The agent must have Visual Studio or the TFVC command-line tools installed (tf.exe).
- You must have proper workspace mappings set up for TFVC to know where to check in the file.