File tree Expand file tree Collapse file tree 4 files changed +32
-3
lines changed Expand file tree Collapse file tree 4 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,10 @@ Import-Module $PSScriptRoot\ps_modules\VstsAzureHelpers_
6363
6464$endpoint = Get-VstsEndpoint - Name $connectedServiceName - Require
6565
66+ # Update PSModulePath for hosted agent
67+ . " $PSScriptRoot \Utility.ps1"
68+ CleanUp- PSModulePathForHostedAgent
69+
6670if (Get-Module Az.Accounts - ListAvailable){
6771 Initialize-AzModule - Endpoint $endpoint
6872}
@@ -75,7 +79,6 @@ Import-VstsLocStrings -LiteralPath $PSScriptRoot/Task.json
7579
7680# Load all dependent files for execution
7781. " $PSScriptRoot \AzureFileCopyRemoteJob.ps1"
78- . " $PSScriptRoot \Utility.ps1"
7982
8083# Enabling detailed logging only when system.debug is true
8184$enableDetailedLogging = ($env: system_debug -eq " true" )
Original file line number Diff line number Diff line change @@ -1301,4 +1301,30 @@ function Get-InvokeRemoteScriptParameters
13011301 protocol = $protocol ;
13021302 sessionOption = $sessionOption
13031303 }
1304+ }
1305+
1306+ function CleanUp-PSModulePathForHostedAgent {
1307+ # Clean up PSModulePath for hosted agent
1308+ $azureRMModulePath = " C:\Modules\azurerm_2.1.0"
1309+ $azureModulePath = " C:\Modules\azure_2.1.0"
1310+ $newEnvPSModulePath = $env: PSModulePath
1311+
1312+ if ($newEnvPSModulePath.split (" ;" ) -contains $azureRMModulePath ) {
1313+ $newEnvPSModulePath = (($newEnvPSModulePath ).Split(" ;" ) | ? { $_ -ne $azureRMModulePath }) -join " ;"
1314+ write-verbose " $azureRMModulePath removed. Restart the prompt for the changes to take effect."
1315+ }
1316+ else {
1317+ write-verbose " $azureRMModulePath is not present in $newEnvPSModulePath "
1318+ }
1319+
1320+ if ($newEnvPSModulePath.split (" ;" ) -contains $azureModulePath ) {
1321+ $newEnvPSModulePath = (($newEnvPSModulePath ).Split(" ;" ) | ? { $_ -ne $azureModulePath }) -join " ;"
1322+ write-verbose " $azureModulePath removed. Restart the prompt for the changes to take effect."
1323+ }
1324+ else {
1325+ write-verbose " $azureModulePath is not present in $newEnvPSModulePath "
1326+ }
1327+
1328+ $azPSModulePath = " C:\Modules\az_3.1.0"
1329+ $env: PSModulePath = $azPSModulePath + " ;" + $newEnvPSModulePath
13041330}
Original file line number Diff line number Diff line change 1313 "author" : " Microsoft Corporation" ,
1414 "version" : {
1515 "Major" : 4 ,
16- "Minor" : 165 ,
16+ "Minor" : 166 ,
1717 "Patch" : 0
1818 },
1919 "preview" : true ,
Original file line number Diff line number Diff line change 1313 "author" : " Microsoft Corporation" ,
1414 "version" : {
1515 "Major" : 4 ,
16- "Minor" : 165 ,
16+ "Minor" : 166 ,
1717 "Patch" : 0
1818 },
1919 "preview" : true ,
You can’t perform that action at this time.
0 commit comments