@@ -17,7 +17,8 @@ function Get-SavedModulePath {
1717
1818function Update-PSModulePathForHostedAgent {
1919 [CmdletBinding ()]
20- param ([string ] $targetAzurePs )
20+ param ([string ] $targetAzurePs ,
21+ [string ] $authScheme )
2122 Trace-VstsEnteringInvocation $MyInvocation
2223 try {
2324 if ($targetAzurePs ) {
@@ -28,10 +29,22 @@ function Update-PSModulePathForHostedAgent {
2829 $hostedAgentAzureRmModulePath = Get-LatestModule - patternToMatch " ^azurerm_[0-9]+\.[0-9]+\.[0-9]+$" - patternToExtract " [0-9]+\.[0-9]+\.[0-9]+$" - Classic:$false
2930 $hostedAgentAzureModulePath = Get-LatestModule - patternToMatch " ^azure_[0-9]+\.[0-9]+\.[0-9]+$" - patternToExtract " [0-9]+\.[0-9]+\.[0-9]+$" - Classic:$true
3031 }
31- $env: PSModulePath = $hostedAgentAzureRmModulePath + " ;" + $env: PSModulePath
32- $env: PSModulePath = $env: PSModulePath.TrimStart (' ;' )
33- $env: PSModulePath = $hostedAgentAzureModulePath + " ;" + $env: PSModulePath
34- $env: PSModulePath = $env: PSModulePath.TrimStart (' ;' )
32+
33+ if ($authScheme -eq ' ServicePrincipal' -or $authScheme -eq ' ' )
34+ {
35+ $env: PSModulePath = $hostedAgentAzureModulePath + " ;" + $env: PSModulePath
36+ $env: PSModulePath = $env: PSModulePath.TrimStart (' ;' )
37+ $env: PSModulePath = $hostedAgentAzureRmModulePath + " ;" + $env: PSModulePath
38+ $env: PSModulePath = $env: PSModulePath.TrimStart (' ;' )
39+ }
40+ else
41+ {
42+ $env: PSModulePath = $hostedAgentAzureRmModulePath + " ;" + $env: PSModulePath
43+ $env: PSModulePath = $env: PSModulePath.TrimStart (' ;' )
44+ $env: PSModulePath = $hostedAgentAzureModulePath + " ;" + $env: PSModulePath
45+ $env: PSModulePath = $env: PSModulePath.TrimStart (' ;' )
46+ }
47+
3548 } finally {
3649 Write-Verbose " The updated value of the PSModulePath is: $ ( $env: PSModulePath ) "
3750 Trace-VstsLeavingInvocation $MyInvocation
0 commit comments