How to connect TFS using PowerShell

220 Views Asked by At

I'm trying to add TFS connection in my PowerShell script but I'm just wondering why it's still saying "Invoke-RestMethod : Unable to connect to the remote server" so I would be really appreciated if I can get any help or suggestion.

I have access permission to that Repo. I just couldn't figure out a way to connect it using PowerShell.

#Key File information for secure connection
$username = "UserName"
$secpasswd = ConvertTo-SecureString -String "Password" -AsPlainText -Force
$UserCredential = New-Object -TypeName "System.Management.Automation.PSCredential" -ArgumentList $username, $secpasswd


$uri = 'http://tfs.company.com/tfs/UEE/111470/_apis/git/repositories/E9u09e-3e27-4c18-9527-8600bb2b3441?api-version=4.1'


$invRestMethParams = @{
    Credential = $UserCredential
    Uri = $uri
    Method = 'Get'
    ContentType = 'application/json'
}
$project = Invoke-RestMethod @invRestMethParams
$project.value
1

There are 1 best solutions below

0
Shamrai Aleksander On

TFS uses port 8080 by default. Can you check the connection to?

'http://tfs.company.com:8080/tfs/UEE.....'