Module/DevOps/Get-BCSDevOpsItem.ps1
<#
.SYNOPSIS Get a DevOps file .DESCRIPTION Gets a spceific file from a DevOps repositiry .PARAMETER organisation DevOps Organisation Name, Default BrightComSolutions .PARAMETER projectName DevOps Project Name .PARAMETER sourcePat DevOps Pwesonal Access Token. .EXAMPLE Get-BCSDevOpsPipelines -projectName "MyProjectName" -sourcePat (Get-BCSSecureString -InputString "MyDevOpsPat") .NOTES Author: Mathias Stjernfelt Website: http://www.brightcom.se #> function Get-BCSDevOpsItem { Param ( [Parameter(Mandatory = $false)] [string]$organisation = "BrightComSolutions", [Parameter(Mandatory = $true)] [string]$projectName, [Parameter(Mandatory = $true)] [string]$repositoryId, [Parameter(Mandatory = $true)] [string]$path, [Parameter(Mandatory = $true)] [string]$branch, [Parameter(Mandatory = $true)] [securestring]$sourcePat ) try { $fullOrgUrl = "https://dev.azure.com/$organisation"; $Pat = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sourcePat)) $encodedPat = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes(":$pat")) $headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]" $headers.Add("Authorization", "Basic $encodedPat") $url = [uri]::EscapeUriString("$fullOrgUrl/_apis/git/repositories/$repositoryId/items?scopePath=$path&download=true&api-version=6.1-preview.1&version&Descriptor.versionType=branch&versionDescriptor.version=$branch") $response = Invoke-RestMethod $url -Method 'GET' -Headers $headers $response } catch { throw $_; } } Export-ModuleMember -Function Get-BCSDevOpsItem |