Skip to content

Commit 2e6f045

Browse files
authored
Removing warning of AzureRm module (#12407)
* Removing warning of AzureRm mosule * Adding latest module of Az
1 parent 5c985ad commit 2e6f045

File tree

4 files changed

+32
-3
lines changed

4 files changed

+32
-3
lines changed

Tasks/AzureFileCopyV4/AzureFileCopy.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff 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+
6670
if (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")

Tasks/AzureFileCopyV4/Utility.ps1

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

Tasks/AzureFileCopyV4/task.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"author": "Microsoft Corporation",
1414
"version": {
1515
"Major": 4,
16-
"Minor": 165,
16+
"Minor": 166,
1717
"Patch": 0
1818
},
1919
"preview": true,

Tasks/AzureFileCopyV4/task.loc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"author": "Microsoft Corporation",
1414
"version": {
1515
"Major": 4,
16-
"Minor": 165,
16+
"Minor": 166,
1717
"Patch": 0
1818
},
1919
"preview": true,

0 commit comments

Comments
 (0)