Skip to content

Commit f1d35dd

Browse files
authored
Fixed AzureRm and Az module warning (#19982)
1 parent 132432b commit f1d35dd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+375
-372
lines changed

Tasks/AzureFileCopyV4/Utility.ps1

+19-18
Original file line numberDiff line numberDiff line change
@@ -1347,27 +1347,28 @@ function Get-InvokeRemoteScriptParameters
13471347
}
13481348

13491349
function CleanUp-PSModulePathForHostedAgent {
1350+
1351+
# Define the module paths to clean up
1352+
$modulePaths = @(
1353+
"C:\Modules\azurerm_2.1.0",
1354+
"C:\\Modules\azurerm_2.1.0",
1355+
"C:\Modules\azure_2.1.0",
1356+
"C:\\Modules\azure_2.1.0"
1357+
)
1358+
13501359
# Clean up PSModulePath for hosted agent
1351-
$azureRMModulePath = "C:\Modules\azurerm_2.1.0"
1352-
$azureModulePath = "C:\Modules\azure_2.1.0"
13531360
$newEnvPSModulePath = $env:PSModulePath
1354-
1355-
if ($newEnvPSModulePath.split(";") -contains $azureRMModulePath) {
1356-
$newEnvPSModulePath = (($newEnvPSModulePath).Split(";") | ? { $_ -ne $azureRMModulePath }) -join ";"
1357-
write-verbose "$azureRMModulePath removed. Restart the prompt for the changes to take effect."
1358-
}
1359-
else {
1360-
write-verbose "$azureRMModulePath is not present in $newEnvPSModulePath"
1361-
}
1362-
1363-
if ($newEnvPSModulePath.split(";") -contains $azureModulePath) {
1364-
$newEnvPSModulePath = (($newEnvPSModulePath).Split(";") | ? { $_ -ne $azureModulePath }) -join ";"
1365-
write-verbose "$azureModulePath removed. Restart the prompt for the changes to take effect."
1366-
}
1367-
else {
1368-
write-verbose "$azureModulePath is not present in $newEnvPSModulePath"
1361+
1362+
foreach ($modulePath in $modulePaths) {
1363+
if ($newEnvPSModulePath.split(";") -contains $modulePath) {
1364+
$newEnvPSModulePath = (($newEnvPSModulePath).Split(";") | ? { $_ -ne $modulePath }) -join ";"
1365+
Write-Verbose "$modulePath removed. Restart the prompt for the changes to take effect."
1366+
}
1367+
else {
1368+
Write-Verbose "$modulePath is not present in $newEnvPSModulePath"
1369+
}
13691370
}
1370-
1371+
13711372
if (Test-Path "C:\Modules\az_*") {
13721373
$azPSModulePath = (Get-ChildItem "C:\Modules\az_*" -Directory `
13731374
| Sort-Object { [version]$_.Name.Split('_')[-1] } `

Tasks/AzureFileCopyV4/task.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"version": {
1515
"Major": 4,
1616
"Minor": 241,
17-
"Patch": 0
17+
"Patch": 2
1818
},
1919
"demands": [
2020
"azureps"

Tasks/AzureFileCopyV4/task.loc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"version": {
1515
"Major": 4,
1616
"Minor": 241,
17-
"Patch": 0
17+
"Patch": 2
1818
},
1919
"demands": [
2020
"azureps"

Tasks/AzureFileCopyV5/Utility.ps1

+19-18
Original file line numberDiff line numberDiff line change
@@ -1361,27 +1361,28 @@ function Get-InvokeRemoteScriptParameters
13611361
}
13621362

13631363
function CleanUp-PSModulePathForHostedAgent {
1364+
1365+
# Define the module paths to clean up
1366+
$modulePaths = @(
1367+
"C:\Modules\azurerm_2.1.0",
1368+
"C:\\Modules\azurerm_2.1.0",
1369+
"C:\Modules\azure_2.1.0",
1370+
"C:\\Modules\azure_2.1.0"
1371+
)
1372+
13641373
# Clean up PSModulePath for hosted agent
1365-
$azureRMModulePath = "C:\Modules\azurerm_2.1.0"
1366-
$azureModulePath = "C:\Modules\azure_2.1.0"
13671374
$newEnvPSModulePath = $env:PSModulePath
1368-
1369-
if ($newEnvPSModulePath.split(";") -contains $azureRMModulePath) {
1370-
$newEnvPSModulePath = (($newEnvPSModulePath).Split(";") | ? { $_ -ne $azureRMModulePath }) -join ";"
1371-
write-verbose "$azureRMModulePath removed. Restart the prompt for the changes to take effect."
1372-
}
1373-
else {
1374-
write-verbose "$azureRMModulePath is not present in $newEnvPSModulePath"
1375-
}
1376-
1377-
if ($newEnvPSModulePath.split(";") -contains $azureModulePath) {
1378-
$newEnvPSModulePath = (($newEnvPSModulePath).Split(";") | ? { $_ -ne $azureModulePath }) -join ";"
1379-
write-verbose "$azureModulePath removed. Restart the prompt for the changes to take effect."
1380-
}
1381-
else {
1382-
write-verbose "$azureModulePath is not present in $newEnvPSModulePath"
1375+
1376+
foreach ($modulePath in $modulePaths) {
1377+
if ($newEnvPSModulePath.split(";") -contains $modulePath) {
1378+
$newEnvPSModulePath = (($newEnvPSModulePath).Split(";") | ? { $_ -ne $modulePath }) -join ";"
1379+
Write-Verbose "$modulePath removed. Restart the prompt for the changes to take effect."
1380+
}
1381+
else {
1382+
Write-Verbose "$modulePath is not present in $newEnvPSModulePath"
1383+
}
13831384
}
1384-
1385+
13851386
if (Test-Path "C:\Modules\az_*") {
13861387
$azPSModulePath = (Get-ChildItem "C:\Modules\az_*" -Directory `
13871388
| Sort-Object { [version]$_.Name.Split('_')[-1] } `

Tasks/AzureFileCopyV5/task.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"version": {
1515
"Major": 5,
1616
"Minor": 241,
17-
"Patch": 0
17+
"Patch": 2
1818
},
1919
"demands": [
2020
"azureps"

Tasks/AzureFileCopyV5/task.loc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"version": {
1515
"Major": 5,
1616
"Minor": 241,
17-
"Patch": 0
17+
"Patch": 2
1818
},
1919
"demands": [
2020
"azureps"

Tasks/AzureFileCopyV6/Utility.ps1

+19-18
Original file line numberDiff line numberDiff line change
@@ -1348,27 +1348,28 @@ function Get-InvokeRemoteScriptParameters
13481348
}
13491349

13501350
function CleanUp-PSModulePathForHostedAgent {
1351+
1352+
# Define the module paths to clean up
1353+
$modulePaths = @(
1354+
"C:\Modules\azurerm_2.1.0",
1355+
"C:\\Modules\azurerm_2.1.0",
1356+
"C:\Modules\azure_2.1.0",
1357+
"C:\\Modules\azure_2.1.0"
1358+
)
1359+
13511360
# Clean up PSModulePath for hosted agent
1352-
$azureRMModulePath = "C:\Modules\azurerm_2.1.0"
1353-
$azureModulePath = "C:\Modules\azure_2.1.0"
13541361
$newEnvPSModulePath = $env:PSModulePath
1355-
1356-
if ($newEnvPSModulePath.split(";") -contains $azureRMModulePath) {
1357-
$newEnvPSModulePath = (($newEnvPSModulePath).Split(";") | ? { $_ -ne $azureRMModulePath }) -join ";"
1358-
write-verbose "$azureRMModulePath removed. Restart the prompt for the changes to take effect."
1359-
}
1360-
else {
1361-
write-verbose "$azureRMModulePath is not present in $newEnvPSModulePath"
1362-
}
1363-
1364-
if ($newEnvPSModulePath.split(";") -contains $azureModulePath) {
1365-
$newEnvPSModulePath = (($newEnvPSModulePath).Split(";") | ? { $_ -ne $azureModulePath }) -join ";"
1366-
write-verbose "$azureModulePath removed. Restart the prompt for the changes to take effect."
1367-
}
1368-
else {
1369-
write-verbose "$azureModulePath is not present in $newEnvPSModulePath"
1362+
1363+
foreach ($modulePath in $modulePaths) {
1364+
if ($newEnvPSModulePath.split(";") -contains $modulePath) {
1365+
$newEnvPSModulePath = (($newEnvPSModulePath).Split(";") | ? { $_ -ne $modulePath }) -join ";"
1366+
Write-Verbose "$modulePath removed. Restart the prompt for the changes to take effect."
1367+
}
1368+
else {
1369+
Write-Verbose "$modulePath is not present in $newEnvPSModulePath"
1370+
}
13701371
}
1371-
1372+
13721373
if (Test-Path "C:\Modules\az_*") {
13731374
$azPSModulePath = (Get-ChildItem "C:\Modules\az_*" -Directory `
13741375
| Sort-Object { [version]$_.Name.Split('_')[-1] } `

Tasks/AzureFileCopyV6/task.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"version": {
1515
"Major": 6,
1616
"Minor": 241,
17-
"Patch": 0
17+
"Patch": 2
1818
},
1919
"demands": [
2020
"azureps"

Tasks/AzureFileCopyV6/task.loc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"version": {
1515
"Major": 6,
1616
"Minor": 241,
17-
"Patch": 0
17+
"Patch": 2
1818
},
1919
"demands": [
2020
"azureps"

Tasks/AzurePowerShellV4/Utility.ps1

+16-17
Original file line numberDiff line numberDiff line change
@@ -178,25 +178,24 @@ function Get-LatestModuleLinux {
178178
}
179179

180180
function CleanUp-PSModulePathForHostedAgent {
181+
# Define the module paths to clean up
182+
$modulePaths = @(
183+
"C:\Modules\azurerm_2.1.0",
184+
"C:\\Modules\azurerm_2.1.0",
185+
"C:\Modules\azure_2.1.0",
186+
"C:\\Modules\azure_2.1.0"
187+
)
188+
181189
# Clean up PSModulePath for hosted agent
182-
$azureRMModulePath = "C:\Modules\azurerm_2.1.0"
183-
$azureModulePath = "C:\Modules\azure_2.1.0"
184190
$azPSModulePath = $env:PSModulePath
185-
186-
if ($azPSModulePath.split(";") -contains $azureRMModulePath) {
187-
$azPSModulePath = (($azPSModulePath).Split(";") | ? { $_ -ne $azureRMModulePath }) -join ";"
188-
write-verbose "$azureRMModulePath removed. Restart the prompt for the changes to take effect."
189-
}
190-
else {
191-
write-verbose "$azureRMModulePath is not present in $azPSModulePath"
192-
}
193-
194-
if ($azPSModulePath.split(";") -contains $azureModulePath) {
195-
$azPSModulePath = (($azPSModulePath).Split(";") | ? { $_ -ne $azureModulePath }) -join ";"
196-
write-verbose "$azureModulePath removed. Restart the prompt for the changes to take effect."
197-
}
198-
else {
199-
write-verbose "$azureModulePath is not present in $azPSModulePath"
191+
foreach ($modulePath in $modulePaths) {
192+
if ($azPSModulePath.split(";") -contains $modulePath) {
193+
$azPSModulePath = (($azPSModulePath).Split(";") | ? { $_ -ne $modulePath }) -join ";"
194+
Write-Verbose "$modulePath removed. Restart the prompt for the changes to take effect."
195+
}
196+
else {
197+
Write-Verbose "$modulePath is not present in $azPSModulePath"
198+
}
200199
}
201200

202201
$env:PSModulePath = $azPSModulePath

Tasks/AzurePowerShellV4/_buildConfigs/Node20/package-lock.json

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tasks/AzurePowerShellV4/_buildConfigs/Node20/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"agent-base": "6.0.2",
1111
"azure-pipelines-task-lib": "^4.11.0",
1212
"azure-pipelines-tasks-azure-arm-rest": "^3.239.0",
13-
"azure-pipelines-tasks-utility-common": "^3.225.0"
13+
"azure-pipelines-tasks-utility-common": "^3.238.0"
1414
},
1515
"devDependencies": {
1616
"typescript": "5.1.6"

Tasks/AzurePowerShellV4/task.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"version": {
1919
"Major": 4,
2020
"Minor": 241,
21-
"Patch": 0
21+
"Patch": 2
2222
},
2323
"releaseNotes": "Added support for Az Module and cross platform agents.",
2424
"groups": [

Tasks/AzurePowerShellV4/task.loc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"version": {
1919
"Major": 4,
2020
"Minor": 241,
21-
"Patch": 0
21+
"Patch": 2
2222
},
2323
"releaseNotes": "ms-resource:loc.releaseNotes",
2424
"groups": [

Tasks/AzurePowerShellV5/Utility.ps1

+16-17
Original file line numberDiff line numberDiff line change
@@ -178,25 +178,24 @@ function Get-LatestModuleLinux {
178178
}
179179

180180
function CleanUp-PSModulePathForHostedAgent {
181+
# Define the module paths to clean up
182+
$modulePaths = @(
183+
"C:\Modules\azurerm_2.1.0",
184+
"C:\\Modules\azurerm_2.1.0",
185+
"C:\Modules\azure_2.1.0",
186+
"C:\\Modules\azure_2.1.0"
187+
)
188+
181189
# Clean up PSModulePath for hosted agent
182-
$azureRMModulePath = "C:\Modules\azurerm_2.1.0"
183-
$azureModulePath = "C:\Modules\azure_2.1.0"
184190
$azPSModulePath = $env:PSModulePath
185-
186-
if ($azPSModulePath.split(";") -contains $azureRMModulePath) {
187-
$azPSModulePath = (($azPSModulePath).Split(";") | ? { $_ -ne $azureRMModulePath }) -join ";"
188-
write-verbose "$azureRMModulePath removed. Restart the prompt for the changes to take effect."
189-
}
190-
else {
191-
write-verbose "$azureRMModulePath is not present in $azPSModulePath"
192-
}
193-
194-
if ($azPSModulePath.split(";") -contains $azureModulePath) {
195-
$azPSModulePath = (($azPSModulePath).Split(";") | ? { $_ -ne $azureModulePath }) -join ";"
196-
write-verbose "$azureModulePath removed. Restart the prompt for the changes to take effect."
197-
}
198-
else {
199-
write-verbose "$azureModulePath is not present in $azPSModulePath"
191+
foreach ($modulePath in $modulePaths) {
192+
if ($azPSModulePath.split(";") -contains $modulePath) {
193+
$azPSModulePath = (($azPSModulePath).Split(";") | ? { $_ -ne $modulePath }) -join ";"
194+
Write-Verbose "$modulePath removed. Restart the prompt for the changes to take effect."
195+
}
196+
else {
197+
Write-Verbose "$modulePath is not present in $azPSModulePath"
198+
}
200199
}
201200

202201
$env:PSModulePath = $azPSModulePath

Tasks/AzurePowerShellV5/_buildConfigs/Node20/package-lock.json

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tasks/AzurePowerShellV5/_buildConfigs/Node20/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"agent-base": "6.0.2",
1111
"azure-pipelines-task-lib": "^4.11.0",
1212
"azure-pipelines-tasks-azure-arm-rest": "^3.239.0",
13-
"azure-pipelines-tasks-utility-common": "^3.225.0"
13+
"azure-pipelines-tasks-utility-common": "^3.238.0"
1414
},
1515
"devDependencies": {
1616
"typescript": "5.1.6"

Tasks/AzurePowerShellV5/task.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"version": {
1919
"Major": 5,
2020
"Minor": 241,
21-
"Patch": 0
21+
"Patch": 2
2222
},
2323
"releaseNotes": "Added support for Az Module and cross platform agents.",
2424
"groups": [

Tasks/AzurePowerShellV5/task.loc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"version": {
1919
"Major": 5,
2020
"Minor": 241,
21-
"Patch": 0
21+
"Patch": 2
2222
},
2323
"releaseNotes": "ms-resource:loc.releaseNotes",
2424
"groups": [
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Default|4.241.0
2-
Node20_229_2|4.241.1
1+
Default|4.241.2
2+
Node20_229_2|4.241.3

0 commit comments

Comments
 (0)