Hi Aditya Mohapatra,
I understood that you want to run an script that inside of your repository from the powershell task on Azure Devops pipeline , in that case replace**$(Build.SourcesDirectory)
** with the appropriate variable that points to the root of your repository.
For example lets assume that your script Export-azureComputeGalleryImageVersion.ps1 is on the directory scripts on your respository so you can update like this:
- task: AzurePowerShell@5
displayName: "Execute Export File in VM to Download Image Version in VHD"
inputs:
azureSubscription: 'SBX-kpmgnp'
ScriptType: 'InlineScript'
Inline: |
$scriptPath = '$(Build.SourcesDirectory)/scripts/Export-AzureComputeGalleryImageVersion.ps1'
$params = @{
ImageDefinitionName = "VMImageDef"
ComputeGalleryName = "VMImageGallery"
ComputeGalleryResourceGroupName = "AzureImagePOC"
ImageVersionName = "1.0.9"
}
Invoke-AzVMRunCommand -ResourceGroupName 'IT' -VMName 'TestVM01' -CommandId 'RunPowerShellScript' -ScriptPath $scriptPath -Parameter $params
azurePowerShellVersion: 'LatestVersion'
In Azure DevOps pipelines, you can use predefined variables to reference different directories and other useful information (https://learn.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml)
If the information helped address your question, please Accept the answer.
Luis