microsoft / azure-pipelines-tasks

Tasks for Azure Pipelines
https://aka.ms/tfbuild
MIT License
3.46k stars 2.6k forks source link

AzurePowerShell - Initialize Az in the PowerShell version that execute the given script #13890

Closed Jeej closed 3 years ago

Jeej commented 3 years ago

Required Information

Entering this information will route you directly to the right team and expedite traction.

Question, Bug, or Feature?
Type: Bug

Enter Task Name: AzurePowerShell

Environment

Issue Description

For my project I created a PowerShell script that checks if some resource groups exist in my Azure Subscription and if needed, they created (it does more, but this the essential). The script I made on my local machine with Azure PowerShell (Az) and I use cmdlets like Get-AzContext. To run the script I used on my local machine PowerShell 7, I like the combination of Azure PowerShell and PowerShell 7 better than Windows PowerShell and Azure RM PowerShell.

I am very happy that it is possible with the AzurePowerShell task (V4) to indicate that PowerShell Core should be used with the input "pwsh". On the machine I also installed PowerShell 7 with Azure PowerShell. I haven't installed Azure PowerShell for the Windows PowerShell because other projects use Azure RM PowerShell, and we know from experience that things break when Azure PowerShell is installed.

Unfortunately, the AzurePowerShell task assumes that Az is installed in the running context, this is the "old" Windows PowerShell, this is not the case for me. The task checks if Az is installed and import the module, but it is doing this in the context of the task. After importing the module, it will execute the to the task supplied script in PowerShell Core when the pwsh flag is true.

I think that the initialize of the Az modules (and other initialization steps) should be part of the PowerShell version that will run the script, that is currently not the case.

Initialization in the task is here, while the script is actually executed in the correct PowerShell version here. The Az initialization is defined here, the most important parts there is this (see output below):

$moduleName = "Az.Accounts"
$module = Get-Module -Name $moduleName -ListAvailable | Sort-Object Version -Descending | Select-Object -First 1

Task logs

Below are the task logs of the run, I have removed references to my client.

2020-11-12T12:00:11.5630217Z ##[debug]Evaluating condition for step: 'Execute azure powershell'
2020-11-12T12:00:11.5632601Z ##[debug]Evaluating: SucceededNode()
2020-11-12T12:00:11.5633434Z ##[debug]Evaluating SucceededNode:
2020-11-12T12:00:11.5635293Z ##[debug]=> True
2020-11-12T12:00:11.5636154Z ##[debug]Result: True
2020-11-12T12:00:11.5637025Z ##[section]Starting: Execute azure powershell
2020-11-12T12:00:11.5780996Z ==============================================================================
2020-11-12T12:00:11.5781623Z Task         : Azure PowerShell
2020-11-12T12:00:11.5782155Z Description  : Run a PowerShell script within an Azure environment
2020-11-12T12:00:11.5782679Z Version      : 4.176.3
2020-11-12T12:00:11.5783097Z Author       : Microsoft Corporation
2020-11-12T12:00:11.5783645Z Help         : https://aka.ms/azurepowershelltroubleshooting
2020-11-12T12:00:11.5784244Z ==============================================================================
2020-11-12T12:00:13.9457902Z ##[debug]VstsTaskSdk 0.11.0 commit 7ff27a3e0bdd6f7b06690ae5f5b63cb84d0f23f4
2020-11-12T12:00:14.5092410Z ##[debug]Entering C:\CustomAgent3\_work\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\4.176.3\azurepowershell.ps1.
2020-11-12T12:00:14.5094136Z ##[debug]Loading resource strings from: C:\CustomAgent3\_work\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\4.176.3\Task.json
2020-11-12T12:00:14.5694801Z ##[debug]Loaded 8 strings.
2020-11-12T12:00:14.5753671Z ##[debug]SYSTEM_CULTURE: 'en-US'
2020-11-12T12:00:14.6185877Z ##[debug]Loading resource strings from: C:\CustomAgent3\_work\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\4.176.3\Strings\resources.resjson\en-US\resources.resjson
2020-11-12T12:00:14.6720036Z ##[debug]Loaded 8 strings.
2020-11-12T12:00:14.7054624Z ##[debug]INPUT_SCRIPTTYPE: 'FilePath'
2020-11-12T12:00:14.7263761Z ##[debug]INPUT_SCRIPTPATH: 'C:\CustomAgent3\_work\1631\s\backupapim.ps1'
2020-11-12T12:00:14.7283863Z ##[debug]INPUT_INLINE: '# You can write your azure powershell scripts inline here. 
2020-11-12T12:00:14.7304960Z ##[debug]# You can also pass predefined and custom variables to this script using arguments'
2020-11-12T12:00:14.7500675Z ##[debug]INPUT_SCRIPTARGUMENTS (empty)
2020-11-12T12:00:14.7502047Z ##[debug]INPUT_ERRORACTIONPREFERENCE: 'stop'
2020-11-12T12:00:14.7698166Z ##[debug]INPUT_FAILONSTANDARDERROR: 'false'
2020-11-12T12:00:14.7989696Z ##[debug] Converted to bool: False
2020-11-12T12:00:14.7990368Z ##[debug]INPUT_TARGETAZUREPS: 'LatestVersion'
2020-11-12T12:00:14.7990948Z ##[debug]INPUT_CUSTOMTARGETAZUREPS (empty)
2020-11-12T12:00:14.7991485Z ##[debug]INPUT_PWSH: 'true'
2020-11-12T12:00:14.7992069Z ##[debug] Converted to bool: True
2020-11-12T12:00:14.7992679Z ##[debug]INPUT_WORKINGDIRECTORY: 'C:\CustomAgent3\_work\1631\s'
2020-11-12T12:00:14.7993352Z ##[debug]INPUT_RESTRICTCONTEXTTOCURRENTTASK: 'false'
2020-11-12T12:00:14.7994093Z ##[debug] Converted to bool: False
2020-11-12T12:00:14.7994619Z ## Validating Inputs
2020-11-12T12:00:14.8006088Z ## Validating Inputs Complete
2020-11-12T12:00:14.8018646Z ## Initializing Az module
2020-11-12T12:00:14.9296046Z ##[debug]INPUT_CONNECTEDSERVICENAMEARM: 'GUID1'
2020-11-12T12:00:14.9889362Z ##[debug]ENDPOINT_URL_GUID1: 'https://management.azure.com/'
2020-11-12T12:00:14.9890849Z ##[debug]ENDPOINT_AUTH_GUID1: '********'
2020-11-12T12:00:14.9903630Z ##[debug]ENDPOINT_DATA_GUID1: '{"subscriptionId":"SUBSCRIPTIONID1","subscriptionName":"CLIENT API","environment":"AzureCloud","scopeLevel":"Subscription","creationMode":"Manual","azureSpnPermissions":"[{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"RESOURCEGROUP1\",\"vault\":\"keyVaultCustom\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"RESOURCEGROUP1\",\"vault\":\"keyVaultCustom\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"RESOURCEGROUP1\",\"vault\":\"keyVaultCustom\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"RESOURCEGROUP2\",\"vault\":\"VAULT1\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"APP1\",\"vault\":\"APP1\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"APP1\",\"vault\":\"APP1\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"APP1\",\"vault\":\"APP1\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"RESOURCEGROUP1\",\"vault\":\"APP2\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"RESOURCEGROUP1\",\"vault\":\"APP2\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"RESOURCEGROUP1\",\"vault\":\"APP2\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"RESOURCEGROUP1\",\"vault\":\"APP3\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"RESOURCEGROUP1\",\"vault\":\"APP3\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"RESOURCEGROUP1\",\"vault\":\"APP4\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"RESOURCEGROUP1\",\"vault\":\"APP4\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"RESOURCEGROUP1\",\"vault\":\"APP4\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"RESOURCEGROUP1\",\"vault\":\"APP4\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"RESOURCEGROUP1\",\"vault\":\"APP5\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"RESOURCEGROUP1\",\"vault\":\"APP4\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"RESOURCEGROUP1\",\"vault\":\"APP4\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"RESOURCEGROUP1\",\"vault\":\"APP4\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"RESOURCEGROUP1\",\"vault\":\"APP4\"}]","environmentUrl":"https://management.azure.com/","galleryUrl":"https://gallery.azure.com/","serviceManagementUrl":"https://management.core.windows.net/","resourceManagerUrl":"https://management.azure.com/","activeDirectoryAuthority":"https://login.microsoftonline.com/","environmentAuthorityUrl":"https://login.windows.net/","graphUrl":"https://graph.windows.net/","managementPortalUrl":"https://manage.windowsazure.com/","armManagementPortalUrl":"https://portal.azure.com/","activeDirectoryServiceEndpointResourceId":"https://management.core.windows.net/","sqlDatabaseDnsSuffix":".database.windows.net","AzureKeyVaultDnsSuffix":"vault.azure.net","AzureKeyVaultServiceEndpointResourceId":"https://vault.azure.net","StorageEndpointSuffix":"core.windows.net","EnableAdfsAuthentication":"false"}'
2020-11-12T12:00:14.9973083Z ##[debug]C:\Modules\azurerm_2.1.0 is not present in C:\Windows\ServiceProfiles\NetworkService\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules\;C:\Program Files (x86)\Microsoft SQL Server\130\Tools\PowerShell\Modules\;c:\Program Files\Microsoft Security Client\MpProvider\;C:\Program Files\Microsoft Monitoring Agent\Agent\AzureAutomation\7.3.837.0;C:\Program Files\Microsoft Monitoring Agent\Agent\PowerShell\
2020-11-12T12:00:15.0221930Z ##[debug]C:\Modules\azure_2.1.0 is not present in C:\Windows\ServiceProfiles\NetworkService\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules\;C:\Program Files (x86)\Microsoft SQL Server\130\Tools\PowerShell\Modules\;c:\Program Files\Microsoft Security Client\MpProvider\;C:\Program Files\Microsoft Monitoring Agent\Agent\AzureAutomation\7.3.837.0;C:\Program Files\Microsoft Monitoring Agent\Agent\PowerShell\
2020-11-12T12:00:15.0390178Z ##[debug]The updated value of the PSModulePath is: C:\Windows\ServiceProfiles\NetworkService\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules\;C:\Program Files (x86)\Microsoft SQL Server\130\Tools\PowerShell\Modules\;c:\Program Files\Microsoft Security Client\MpProvider\;C:\Program Files\Microsoft Monitoring Agent\Agent\AzureAutomation\7.3.837.0;C:\Program Files\Microsoft Monitoring Agent\Agent\PowerShell\
2020-11-12T12:00:15.0477828Z ##[debug]Loading module from path 'C:\CustomAgent3\_work\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\4.176.3\ps_modules\VstsAzureHelpers_\VstsAzureHelpers_.psm1'.
2020-11-12T12:00:15.0833309Z ##[debug]$OVERRIDING $global:DebugPreference from 'Continue' to 'SilentlyContinue'.
2020-11-12T12:00:15.0875430Z ##[debug]Loading resource strings from: C:\CustomAgent3\_work\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\4.176.3\ps_modules\VstsAzureHelpers_/module.json
2020-11-12T12:00:15.2932427Z ##[debug]Loaded 13 strings.
2020-11-12T12:00:15.3506306Z ##[debug]SYSTEM_CULTURE: 'en-US'
2020-11-12T12:00:15.3994959Z ##[debug]Loading resource strings from: C:\CustomAgent3\_work\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\4.176.3\ps_modules\VstsAzureHelpers_\Strings\resources.resjson\en-US\resources.resjson
2020-11-12T12:00:15.4647765Z ##[debug]Loaded 13 strings.
2020-11-12T12:00:15.4962616Z ##[debug]Entering Get-VstsWebProxy.
2020-11-12T12:00:15.5277167Z ##[debug]AGENT_VERSION: '2.175.2'
2020-11-12T12:00:15.5284376Z ##[debug]AGENT_PROXYURL (empty)
2020-11-12T12:00:15.5338516Z ##[debug]AGENT_PROXYUSERNAME (empty)
2020-11-12T12:00:15.5675446Z ##[debug]AGENT_PROXYPASSWORD (empty)
2020-11-12T12:00:15.5756559Z ##[debug]AGENT_PROXYBYPASSLIST (empty)
2020-11-12T12:00:15.6283606Z ##[debug]Leaving Get-VstsWebProxy.
2020-11-12T12:00:15.7048298Z ##[debug]Loading module from path 'C:\CustomAgent3\_work\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\4.176.3\ps_modules\TlsHelper_\TlsHelper_.psm1'.
2020-11-12T12:00:15.7231228Z ##[debug]Loading resource strings from: C:\CustomAgent3\_work\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\4.176.3\ps_modules\TlsHelper_/module.json
2020-11-12T12:00:15.7423363Z ##[debug]Loaded 3 strings.
2020-11-12T12:00:15.7459437Z ##[debug]SYSTEM_CULTURE: 'en-US'
2020-11-12T12:00:15.8940214Z ##[debug]Loading resource strings from: C:\CustomAgent3\_work\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\4.176.3\ps_modules\TlsHelper_\Strings\resources.resjson\en-US\resources.resjson
2020-11-12T12:00:15.9193709Z ##[debug]Loaded 3 strings.
2020-11-12T12:00:15.9232752Z ##[debug]Exporting function 'Add-Tls12InSession'.
2020-11-12T12:00:15.9545849Z ##[debug]Exporting function 'Assert-TlsError'.
2020-11-12T12:00:15.9803832Z ##[debug]Importing function 'Add-Tls12InSession'.
2020-11-12T12:00:16.0080372Z ##[debug]Importing function 'Assert-TlsError'.
2020-11-12T12:00:16.0333371Z ##[debug]TLS 1.2 already present in session.
2020-11-12T12:00:16.2948501Z ##[debug]Exporting function 'Initialize-Azure'.
2020-11-12T12:00:16.3051225Z ##[debug]Exporting function 'CmdletHasMember'.
2020-11-12T12:00:16.3059855Z ##[debug]Exporting function 'Remove-EndpointSecrets'.
2020-11-12T12:00:16.4134400Z ##[debug]Exporting function 'Initialize-AzureRMModule'.
2020-11-12T12:00:16.4288486Z ##[debug]Exporting function 'Initialize-AzModule'.
2020-11-12T12:00:16.4389035Z ##[debug]Exporting function 'Disconnect-AzureAndClearContext'.
2020-11-12T12:00:16.4400505Z ##[debug]Exporting function 'Update-PSModulePathForHostedAgentWithLatestModule'.
2020-11-12T12:00:16.4419128Z ##[debug]Importing function 'CmdletHasMember'.
2020-11-12T12:00:16.4596490Z ##[debug]Importing function 'Disconnect-AzureAndClearContext'.
2020-11-12T12:00:16.4631511Z ##[debug]Importing function 'Initialize-AzModule'.
2020-11-12T12:00:16.4646906Z ##[debug]Importing function 'Initialize-Azure'.
2020-11-12T12:00:16.4648648Z ##[debug]Importing function 'Initialize-AzureRMModule'.
2020-11-12T12:00:16.4649652Z ##[debug]Importing function 'Remove-EndpointSecrets'.
2020-11-12T12:00:16.4882290Z ##[debug]Importing function 'Update-PSModulePathForHostedAgentWithLatestModule'.
2020-11-12T12:00:16.4945617Z ##[debug]Entering Initialize-AzModule.
2020-11-12T12:00:16.4957201Z ##[debug] Endpoint: '@{Url=https://management.azure.com/; Data=; Auth=}'
2020-11-12T12:00:16.4957970Z ##[debug] azVersion: ''
2020-11-12T12:00:16.5209182Z ##[debug]Env:PSModulePath: 'C:\Windows\ServiceProfiles\NetworkService\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules\;C:\Program Files (x86)\Microsoft SQL Server\130\Tools\PowerShell\Modules\;c:\Program Files\Microsoft Security Client\MpProvider\;C:\Program Files\Microsoft Monitoring Agent\Agent\AzureAutomation\7.3.837.0;C:\Program Files\Microsoft Monitoring Agent\Agent\PowerShell\'
2020-11-12T12:00:16.5276302Z ##[debug]Entering Import-AzModule.
2020-11-12T12:00:16.5277553Z ##[debug] azVersion: ''
2020-11-12T12:00:16.5637088Z ##[debug]Attempting to find the module 'Az.Accounts' from the module path.
2020-11-12T12:00:16.5898245Z ##[debug]No module found with name: Az.Accounts
2020-11-12T12:00:16.6032284Z ##[debug]Leaving Import-AzModule.
2020-11-12T12:00:16.6215983Z ##[debug]Leaving Initialize-AzModule.
2020-11-12T12:00:16.6498519Z ##[error]Initializing Az module failed: For troubleshooting, refer: https://aka.ms/azurepowershelltroubleshooting
2020-11-12T12:00:16.6512133Z ##[debug]Processed: ##vso[task.logissue type=error]Initializing Az module failed: For troubleshooting, refer: https://aka.ms/azurepowershelltroubleshooting
2020-11-12T12:00:16.6718650Z ##[debug]Caught exception from task script.
2020-11-12T12:00:16.6723920Z ##[debug]Error record:
2020-11-12T12:00:16.7563144Z ##[debug]Could not find the modules: 'Az.Accounts' with Version: ''. If the module was recently installed, retry after restarting the Azure Pipelines task agent.
2020-11-12T12:00:16.7808361Z ##[debug]At C:\CustomAgent3\_work\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\4.176.3\ps_modules\VstsAzureHelpers_\InitializeAzModuleFunctions.ps1:53 char:13
2020-11-12T12:00:16.7852049Z ##[debug]+             throw (Get-VstsLocString -Key AZ_ModuleNotFound -Argument ...
2020-11-12T12:00:16.7852843Z ##[debug]+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2020-11-12T12:00:16.7853845Z ##[debug]    + CategoryInfo          : OperationStopped: (Could not find ...nes task ag    ent.:String) [], RuntimeException
2020-11-12T12:00:16.7855087Z ##[debug]    + FullyQualifiedErrorId : Could not find the modules: 'Az.Accounts' with V    ersion: ''. If the module was recently installed, retry after restarting t    he Azure Pipelines task agent.
2020-11-12T12:00:16.7856003Z ##[debug] 
2020-11-12T12:00:16.7856431Z ##[debug]Script stack trace:
2020-11-12T12:00:16.7857411Z ##[debug]at Import-AzModule, C:\CustomAgent3\_work\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\4.176.3\ps_modules\VstsAzureHelpers_\InitializeAzModuleFunctions.ps1: line 53
2020-11-12T12:00:16.7858886Z ##[debug]at Initialize-AzModule, C:\CustomAgent3\_work\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\4.176.3\ps_modules\VstsAzureHelpers_\InitializeAzModuleFunctions.ps1: line 14
2020-11-12T12:00:16.7860240Z ##[debug]at <ScriptBlock>, C:\CustomAgent3\_work\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\4.176.3\azurepowershell.ps1: line 66
2020-11-12T12:00:16.8049457Z ##[debug]at <ScriptBlock>, <No file>: line 1
2020-11-12T12:00:16.8105976Z ##[debug]at <ScriptBlock>, <No file>: line 22
2020-11-12T12:00:16.8106724Z ##[debug]at <ScriptBlock>, <No file>: line 18
2020-11-12T12:00:16.8237128Z ##[debug]at <ScriptBlock>, <No file>: line 1
2020-11-12T12:00:16.8277060Z ##[debug]Exception:
2020-11-12T12:00:16.8278460Z ##[debug]System.Management.Automation.RuntimeException: Could not find the modules: 'Az.Accounts' with Version: ''. If the module was recently installed, retry after restarting the Azure Pipelines task agent.
2020-11-12T12:00:16.8284079Z ##[error]Could not find the modules: 'Az.Accounts' with Version: ''. If the module was recently installed, retry after restarting the Azure Pipelines task agent.
2020-11-12T12:00:16.8286362Z ##[debug]Processed: ##vso[task.logissue type=error]Could not find the modules: 'Az.Accounts' with Version: ''. If the module was recently installed, retry after restarting the Azure Pipelines task agent.
2020-11-12T12:00:16.8299992Z ##[debug]Processed: ##vso[task.complete result=Failed]
2020-11-12T12:00:16.8724694Z ##[section]Finishing: Execute azure powershell

Here you can see that the Az.Accounts is not installed for Windows PowerShell. When I run the initialize check in PowerShell 7 with Azure Powershell installed I get this:

PS C:\Users\custom-admin> $moduleName = "Az.Accounts"
PS C:\Users\custom-admin> $module = Get-Module -Name $moduleName -ListAvailable | S
ort-Object Version -Descending | Select-Object -First 1
PS C:\Users\custom-admin> $module

    Directory: C:\Program Files\PowerShell\Modules

ModuleType Version    PreRelease Name                                PSEdition
---------- -------    ---------- ----                                ---------
Script     2.1.2                 Az.Accounts                         Core,Desk

So this is good and this why the initialize should be running in the PowerShell version that execute the script.

20shivangi commented 3 years ago

@Jeej Can you please try to use AzurePowerShellV5 instead of V4 version

Jeej commented 3 years ago

@Jeej Can you please try to use AzurePowerShellV5 instead of V4 version

@20shivangi The version I now use is actually V3 instead of V4. I have tried it with V5, with the following pipeline (changed my team name to 'team'):

stages:
  - stage: Test
    displayName: Test new AzurePowerShellTask
    jobs:
      - job: TesTJob
        workspace:
          clean: all
        displayName: Job to test script
        pool: Team Hosted Agents
        steps:
          - script: echo Current job = $(Agent.JobName)

          - task: AzurePowerShell@5
            displayName: 'Execute Azure PowerShell'
            inputs:
              pwsh: true
              Inline: 'Get-AzResourceGroup -Name "EUW-TEAM-TST"'
              azureSubscription: 'Azure Team'
              azurePowerShellVersion: LatestVersion

Also tried this: Inline: Get-AzResourceGroup -Name EUW-TEAM-TST This didn't work, probably I did something wrong, this is the error log:

2020-11-18T09:16:37.9576301Z ##[debug]Evaluating condition for step: 'Execute Azure PowerShell'
2020-11-18T09:16:37.9579180Z ##[debug]Evaluating: SucceededNode()
2020-11-18T09:16:37.9580103Z ##[debug]Evaluating SucceededNode:
2020-11-18T09:16:37.9581810Z ##[debug]=> True
2020-11-18T09:16:37.9582713Z ##[debug]Result: True
2020-11-18T09:16:37.9583802Z ##[section]Starting: Execute Azure PowerShell
2020-11-18T09:16:37.9716457Z ==============================================================================
2020-11-18T09:16:37.9717104Z Task         : Azure PowerShell
2020-11-18T09:16:37.9717814Z Description  : Run a PowerShell script within an Azure environment
2020-11-18T09:16:37.9718368Z Version      : 5.176.3
2020-11-18T09:16:37.9718762Z Author       : Microsoft Corporation
2020-11-18T09:16:37.9719199Z Help         : https://aka.ms/azurepowershelltroubleshooting
2020-11-18T09:16:37.9719693Z ==============================================================================
2020-11-18T09:16:39.3843512Z ##[debug]VstsTaskSdk 0.11.0 commit 7ff27a3e0bdd6f7b06690ae5f5b63cb84d0f23f4
2020-11-18T09:16:39.7792695Z ##[debug]Entering C:\TeamAgent3\_work\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\5.176.3\azurepowershell.ps1.
2020-11-18T09:16:39.7842086Z ##[debug]Loading resource strings from: C:\TeamAgent3\_work\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\5.176.3\Task.json
2020-11-18T09:16:39.8314130Z ##[debug]Loaded 9 strings.
2020-11-18T09:16:39.8413651Z ##[debug]SYSTEM_CULTURE: 'en-US'
2020-11-18T09:16:39.8499998Z ##[debug]Loading resource strings from: C:\TeamAgent3\_work\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\5.176.3\Strings\resources.resjson\en-US\resources.resjson
2020-11-18T09:16:39.8950660Z ##[debug]Loaded 9 strings.
2020-11-18T09:16:39.9120522Z ##[debug]INPUT_SCRIPTTYPE: 'FilePath'
2020-11-18T09:16:39.9224853Z ##[debug]INPUT_SCRIPTPATH: 'C:\TeamAgent3\_work\1639\s'
2020-11-18T09:16:39.9244166Z ##[debug]INPUT_INLINE: 'Get-AzResourceGroup -Name EUW-Team-TST'
2020-11-18T09:16:39.9303392Z ##[debug]INPUT_SCRIPTARGUMENTS (empty)
2020-11-18T09:16:39.9439972Z ##[debug]INPUT_ERRORACTIONPREFERENCE: 'stop'
2020-11-18T09:16:39.9466580Z ##[debug]INPUT_FAILONSTANDARDERROR: 'false'
2020-11-18T09:16:39.9524728Z ##[debug] Converted to bool: False
2020-11-18T09:16:39.9558001Z ##[debug]INPUT_TARGETAZUREPS: 'LatestVersion'
2020-11-18T09:16:39.9651098Z ##[debug]INPUT_CUSTOMTARGETAZUREPS (empty)
2020-11-18T09:16:39.9653396Z ##[debug]INPUT_PWSH: 'true'
2020-11-18T09:16:39.9723042Z ##[debug] Converted to bool: True
2020-11-18T09:16:39.9753464Z ##[debug]INPUT_WORKINGDIRECTORY: 'C:\TeamAgent3\_work\1639\s'
2020-11-18T09:16:40.0124891Z ##[debug]INPUT_CONNECTEDSERVICENAMEARM: 'guid'
2020-11-18T09:16:40.0261408Z ##[debug]ENDPOINT_URL_guid: 'https://management.azure.com/'
2020-11-18T09:16:40.0311195Z ##[debug]ENDPOINT_AUTH_guid: '********'
2020-11-18T09:16:40.0387085Z ##[debug]ENDPOINT_DATA_guid: '{"subscriptionId":"subscriptionguid","subscriptionName":"subscriptionname","environment":"AzureCloud","scopeLevel":"Subscription","creationMode":"Manual","azureSpnPermissions":"[{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"some-rg\",\"vault\":\"keyVaultTeam\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"some-rg\",\"vault\":\"keyVaultTeam\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"some-rg\",\"vault\":\"keyVaultTeam\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"EUW-Team-TST\",\"vault\":\"somevault\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"anotherthing\",\"vault\":\"anotherthing\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"anotherthing\",\"vault\":\"anotherthing\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"anotherthing\",\"vault\":\"anotherthing\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"some-rg\",\"vault\":\"nextapp\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"some-rg\",\"vault\":\"nextapp\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"some-rg\",\"vault\":\"nextapp\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"some-rg\",\"vault\":\"nextnextapp\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"some-rg\",\"vault\":\"nextnextapp\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"some-rg\",\"vault\":\"nextapp2\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"some-rg\",\"vault\":\"nextapp2\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"some-rg\",\"vault\":\"nextapp2\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"some-rg\",\"vault\":\"nextapp2\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"some-rg\",\"vault\":\"TeamGeneral-ACC\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"some-rg\",\"vault\":\"nextapp2\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"some-rg\",\"vault\":\"nextapp2\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"some-rg\",\"vault\":\"nextapp2\"},{\"provisioned\":false,\"resourceProvider\":\"Microsoft.KeyVault\",\"resourceGroup\":\"some-rg\",\"vault\":\"nextapp2\"}]","environmentUrl":"https://management.azure.com/","galleryUrl":"https://gallery.azure.com/","serviceManagementUrl":"https://management.core.windows.net/","resourceManagerUrl":"https://management.azure.com/","activeDirectoryAuthority":"https://login.microsoftonline.com/","environmentAuthorityUrl":"https://login.windows.net/","graphUrl":"https://graph.windows.net/","managementPortalUrl":"https://manage.windowsazure.com/","armManagementPortalUrl":"https://portal.azure.com/","activeDirectoryServiceEndpointResourceId":"https://management.core.windows.net/","sqlDatabaseDnsSuffix":".database.windows.net","AzureKeyVaultDnsSuffix":"vault.azure.net","AzureKeyVaultServiceEndpointResourceId":"https://vault.azure.net","StorageEndpointSuffix":"core.windows.net","EnableAdfsAuthentication":"false"}'
2020-11-18T09:16:40.0635987Z Generating script.
2020-11-18T09:16:40.1288622Z ##[debug]Asserting leaf path exists: 'C:\Program Files\PowerShell\7\pwsh.exe'
2020-11-18T09:16:40.1332576Z ========================== Starting Command Output ===========================
2020-11-18T09:16:40.1357046Z ##[debug]Entering Invoke-VstsTool.
2020-11-18T09:16:40.1631467Z ##[debug] Arguments: '-NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'C:\TeamAgent3\_work\_temp\34e0097d-a5be-4b55-bc2c-48492db2d299.ps1'"'
2020-11-18T09:16:40.1634390Z ##[debug] FileName: 'C:\Program Files\PowerShell\7\pwsh.exe'
2020-11-18T09:16:40.1751088Z ##[debug] WorkingDirectory: 'C:\TeamAgent3\_work\1639\s'
2020-11-18T09:16:40.1839747Z ##[command]"C:\Program Files\PowerShell\7\pwsh.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'C:\TeamAgent3\_work\_temp\34e0097d-a5be-4b55-bc2c-48492db2d299.ps1'"
2020-11-18T09:16:40.8742515Z VERBOSE: Loading module from path 'C:\TeamAgent3\_work\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\5.176.3\ps_modules\VstsTaskSdk\VstsTaskSdk.psd1'.
2020-11-18T09:16:40.8749075Z VERBOSE: Loading module from path 'C:\TeamAgent3\_work\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\5.176.3\ps_modules\VstsTaskSdk\VstsTaskSdk.psm1'.
2020-11-18T09:16:40.9660707Z VERBOSE: NonInteractive: True
2020-11-18T09:16:40.9668442Z VERBOSE: Loading compiled helper C:\TeamAgent3\_work\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\5.176.3\ps_modules\VstsTaskSdk\VstsTaskSdk.dll.
2020-11-18T09:16:41.0741333Z VERBOSE: Exporting function 'Find-Match'.
2020-11-18T09:16:41.0742324Z VERBOSE: Exporting function 'New-FindOptions'.
2020-11-18T09:16:41.0747494Z VERBOSE: Exporting function 'New-MatchOptions'.
2020-11-18T09:16:41.0748158Z VERBOSE: Exporting function 'Select-Match'.
2020-11-18T09:16:41.0748819Z VERBOSE: Exporting function 'Get-Endpoint'.
2020-11-18T09:16:41.0749572Z VERBOSE: Exporting function 'Get-SecureFileTicket'.
2020-11-18T09:16:41.0754562Z VERBOSE: Exporting function 'Get-SecureFileName'.
2020-11-18T09:16:41.0755725Z VERBOSE: Exporting function 'Get-Input'.
2020-11-18T09:16:41.0756470Z VERBOSE: Exporting function 'Get-TaskVariable'.
2020-11-18T09:16:41.0757094Z VERBOSE: Exporting function 'Get-TaskVariableInfo'.
2020-11-18T09:16:41.0757703Z VERBOSE: Exporting function 'Set-TaskVariable'.
2020-11-18T09:16:41.0758578Z VERBOSE: Exporting function 'Find-Files'.
2020-11-18T09:16:41.0759215Z VERBOSE: Exporting function 'Get-LocString'.
2020-11-18T09:16:41.0759860Z VERBOSE: Exporting function 'Import-LocStrings'.
2020-11-18T09:16:41.0761310Z VERBOSE: Exporting function 'Write-AddAttachment'.
2020-11-18T09:16:41.0762763Z VERBOSE: Exporting function 'Write-UploadSummary'.
2020-11-18T09:16:41.0764256Z VERBOSE: Exporting function 'Write-SetEndpoint'.
2020-11-18T09:16:41.0767368Z VERBOSE: Exporting function 'Write-AddBuildTag'.
2020-11-18T09:16:41.0768104Z VERBOSE: Exporting function 'Write-AssociateArtifact'.
2020-11-18T09:16:41.0769234Z VERBOSE: Exporting function 'Write-LogDetail'.
2020-11-18T09:16:41.0770000Z VERBOSE: Exporting function 'Write-SetProgress'.
2020-11-18T09:16:41.0770677Z VERBOSE: Exporting function 'Write-SetResult'.
2020-11-18T09:16:41.0772336Z VERBOSE: Exporting function 'Write-SetSecret'.
2020-11-18T09:16:41.0773914Z VERBOSE: Exporting function 'Write-SetVariable'.
2020-11-18T09:16:41.0775316Z VERBOSE: Exporting function 'Write-TaskDebug'.
2020-11-18T09:16:41.0776799Z VERBOSE: Exporting function 'Write-TaskError'.
2020-11-18T09:16:41.0778283Z VERBOSE: Exporting function 'Write-TaskVerbose'.
2020-11-18T09:16:41.0779749Z VERBOSE: Exporting function 'Write-TaskWarning'.
2020-11-18T09:16:41.0781205Z VERBOSE: Exporting function 'Write-UploadFile'.
2020-11-18T09:16:41.0782623Z VERBOSE: Exporting function 'Write-PrependPath'.
2020-11-18T09:16:41.0784131Z VERBOSE: Exporting function 'Write-UpdateBuildNumber'.
2020-11-18T09:16:41.0785584Z VERBOSE: Exporting function 'Write-UploadArtifact'.
2020-11-18T09:16:41.0787028Z VERBOSE: Exporting function 'Write-UploadBuildLog'.
2020-11-18T09:16:41.0788478Z VERBOSE: Exporting function 'Write-UpdateReleaseName'.
2020-11-18T09:16:41.0791060Z VERBOSE: Exporting function 'Get-AssemblyReference'.
2020-11-18T09:16:41.0792646Z VERBOSE: Exporting function 'Get-TfsClientCredentials'.
2020-11-18T09:16:41.0794057Z VERBOSE: Exporting function 'Get-TfsService'.
2020-11-18T09:16:41.0797010Z VERBOSE: Exporting function 'Get-VssCredentials'.
2020-11-18T09:16:41.0797782Z VERBOSE: Exporting function 'Get-VssHttpClient'.
2020-11-18T09:16:41.0798421Z VERBOSE: Exporting function 'Get-WebProxy'.
2020-11-18T09:16:41.0799860Z VERBOSE: Exporting function 'Get-ClientCertificate'.
2020-11-18T09:16:41.0826989Z VERBOSE: Exporting function 'Assert-Agent'.
2020-11-18T09:16:41.0827698Z VERBOSE: Exporting function 'Assert-Path'.
2020-11-18T09:16:41.0828320Z VERBOSE: Exporting function 'Invoke-Tool'.
2020-11-18T09:16:41.0828991Z VERBOSE: Exporting function 'Trace-EnteringInvocation'.
2020-11-18T09:16:41.0831078Z VERBOSE: Exporting function 'Trace-LeavingInvocation'.
2020-11-18T09:16:41.0831768Z VERBOSE: Exporting function 'Trace-Path'.
2020-11-18T09:16:41.0832351Z VERBOSE: Exporting function 'Out-Default'.
2020-11-18T09:16:41.2794327Z ##[debug]Loading resource strings from: C:\TeamAgent3\_work\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\5.176.3\ps_modules\VstsTaskSdk\lib.json
2020-11-18T09:16:41.3616442Z ##[debug]Loaded 16 strings.
2020-11-18T09:16:44.3568738Z ##[debug]SYSTEM_CULTURE: 'en-US'
2020-11-18T09:16:44.3577784Z ##[debug]Loading resource strings from: C:\TeamAgent3\_work\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\5.176.3\ps_modules\VstsTaskSdk\Strings\resources.resjson\en-US\resources.resjson
2020-11-18T09:16:44.3579426Z ##[debug]Loaded 16 strings.
2020-11-18T09:16:44.3580575Z ##[debug]Importing the module 'Microsoft.PowerShell.Security'.
2020-11-18T09:16:44.3581911Z ##[debug]Loading module from path 'C:\program files\powershell\7\Modules\Microsoft.PowerShell.Security\Microsoft.PowerShell.Security.psd1'.
2020-11-18T09:16:44.3583239Z ##[debug]Loading module from path 'C:\Program Files\PowerShell\7\Microsoft.PowerShell.Security.dll'.
2020-11-18T09:16:44.3583914Z ##[debug]Importing cmdlet 'Get-Acl'.
2020-11-18T09:16:44.3584356Z ##[debug]Importing cmdlet 'Set-Acl'.
2020-11-18T09:16:44.3584789Z ##[debug]Importing cmdlet 'New-FileCatalog'.
2020-11-18T09:16:44.3585352Z ##[debug]Importing cmdlet 'Test-FileCatalog'.
2020-11-18T09:16:44.3586090Z ##[debug]Importing cmdlet 'Get-PfxCertificate'.
2020-11-18T09:16:44.3586675Z ##[debug]Importing cmdlet 'Protect-CmsMessage'.
2020-11-18T09:16:44.3587224Z ##[debug]Importing cmdlet 'Get-CmsMessage'.
2020-11-18T09:16:44.3587982Z ##[debug]Importing cmdlet 'Unprotect-CmsMessage'.
2020-11-18T09:16:44.3588584Z ##[debug]Importing cmdlet 'Get-Credential'.
2020-11-18T09:16:44.3589143Z ##[debug]Importing cmdlet 'Get-ExecutionPolicy'.
2020-11-18T09:16:44.3589876Z ##[debug]Importing cmdlet 'Set-ExecutionPolicy'.
2020-11-18T09:16:44.3590944Z ##[debug]Importing cmdlet 'ConvertFrom-SecureString'.
2020-11-18T09:16:44.3591560Z ##[debug]Importing cmdlet 'ConvertTo-SecureString'.
2020-11-18T09:16:44.3592315Z ##[debug]Importing cmdlet 'Get-AuthenticodeSignature'.
2020-11-18T09:16:44.3592931Z ##[debug]Importing cmdlet 'Set-AuthenticodeSignature'.
2020-11-18T09:16:44.3593490Z ##[debug]Exporting cmdlet 'Get-Acl'.
2020-11-18T09:16:44.3594173Z ##[debug]Exporting cmdlet 'Set-Acl'.
2020-11-18T09:16:44.3594735Z ##[debug]Exporting cmdlet 'New-FileCatalog'.
2020-11-18T09:16:44.3595444Z ##[debug]Exporting cmdlet 'Test-FileCatalog'.
2020-11-18T09:16:44.3596021Z ##[debug]Exporting cmdlet 'Get-PfxCertificate'.
2020-11-18T09:16:44.3596723Z ##[debug]Exporting cmdlet 'Protect-CmsMessage'.
2020-11-18T09:16:44.3597306Z ##[debug]Exporting cmdlet 'Get-CmsMessage'.
2020-11-18T09:16:44.3598027Z ##[debug]Exporting cmdlet 'Unprotect-CmsMessage'.
2020-11-18T09:16:44.3598577Z ##[debug]Exporting cmdlet 'Get-Credential'.
2020-11-18T09:16:44.3599307Z ##[debug]Exporting cmdlet 'Get-ExecutionPolicy'.
2020-11-18T09:16:44.3599896Z ##[debug]Exporting cmdlet 'Set-ExecutionPolicy'.
2020-11-18T09:16:44.3600476Z ##[debug]Exporting cmdlet 'ConvertFrom-SecureString'.
2020-11-18T09:16:44.3601249Z ##[debug]Exporting cmdlet 'ConvertTo-SecureString'.
2020-11-18T09:16:44.3601870Z ##[debug]Exporting cmdlet 'Get-AuthenticodeSignature'.
2020-11-18T09:16:44.3602644Z ##[debug]Exporting cmdlet 'Set-AuthenticodeSignature'.
2020-11-18T09:16:44.3603249Z ##[debug]Importing cmdlet 'ConvertFrom-SecureString'.
2020-11-18T09:16:44.3604081Z ##[debug]Importing cmdlet 'ConvertTo-SecureString'.
2020-11-18T09:16:44.3604673Z ##[debug]Importing cmdlet 'Get-Acl'.
2020-11-18T09:16:44.3605244Z ##[debug]Importing cmdlet 'Get-AuthenticodeSignature'.
2020-11-18T09:16:44.3605785Z ##[debug]Importing cmdlet 'Get-CmsMessage'.
2020-11-18T09:16:44.3606353Z ##[debug]Importing cmdlet 'Get-Credential'.
2020-11-18T09:16:44.3606892Z ##[debug]Importing cmdlet 'Get-ExecutionPolicy'.
2020-11-18T09:16:44.3607473Z ##[debug]Importing cmdlet 'Get-PfxCertificate'.
2020-11-18T09:16:44.3608035Z ##[debug]Importing cmdlet 'New-FileCatalog'.
2020-11-18T09:16:44.3608603Z ##[debug]Importing cmdlet 'Protect-CmsMessage'.
2020-11-18T09:16:44.3609139Z ##[debug]Importing cmdlet 'Set-Acl'.
2020-11-18T09:16:44.3609670Z ##[debug]Importing cmdlet 'Set-AuthenticodeSignature'.
2020-11-18T09:16:44.3610492Z ##[debug]Importing cmdlet 'Set-ExecutionPolicy'.
2020-11-18T09:16:44.3611050Z ##[debug]Importing cmdlet 'Test-FileCatalog'.
2020-11-18T09:16:44.3611619Z ##[debug]Importing cmdlet 'Unprotect-CmsMessage'.
2020-11-18T09:16:44.3612061Z VERBOSE: Importing function 'Assert-VstsAgent'.
2020-11-18T09:16:44.3612480Z VERBOSE: Importing function 'Assert-VstsPath'.
2020-11-18T09:16:44.3612912Z VERBOSE: Importing function 'Find-VstsFiles'.
2020-11-18T09:16:44.3613300Z VERBOSE: Importing function 'Find-VstsMatch'.
2020-11-18T09:16:44.3613754Z VERBOSE: Importing function 'Get-VstsAssemblyReference'.
2020-11-18T09:16:44.3614233Z VERBOSE: Importing function 'Get-VstsClientCertificate'.
2020-11-18T09:16:44.3614687Z VERBOSE: Importing function 'Get-VstsEndpoint'.
2020-11-18T09:16:44.3615096Z VERBOSE: Importing function 'Get-VstsInput'.
2020-11-18T09:16:44.3615528Z VERBOSE: Importing function 'Get-VstsLocString'.
2020-11-18T09:16:44.3615963Z VERBOSE: Importing function 'Get-VstsSecureFileName'.
2020-11-18T09:16:44.3616434Z VERBOSE: Importing function 'Get-VstsSecureFileTicket'.
2020-11-18T09:16:44.3616888Z VERBOSE: Importing function 'Get-VstsTaskVariable'.
2020-11-18T09:16:44.3617341Z VERBOSE: Importing function 'Get-VstsTaskVariableInfo'.
2020-11-18T09:16:44.3617814Z VERBOSE: Importing function 'Get-VstsTfsClientCredentials'.
2020-11-18T09:16:44.3618256Z VERBOSE: Importing function 'Get-VstsTfsService'.
2020-11-18T09:16:44.3618710Z VERBOSE: Importing function 'Get-VstsVssCredentials'.
2020-11-18T09:16:44.3619133Z VERBOSE: Importing function 'Get-VstsVssHttpClient'.
2020-11-18T09:16:44.3619591Z VERBOSE: Importing function 'Get-VstsWebProxy'.
2020-11-18T09:16:44.3620177Z VERBOSE: Importing function 'Import-VstsLocStrings'.
2020-11-18T09:16:44.3621091Z VERBOSE: Importing function 'Invoke-VstsTool'.
2020-11-18T09:16:44.3647185Z VERBOSE: Importing function 'New-VstsFindOptions'.
2020-11-18T09:16:44.3647675Z VERBOSE: Importing function 'New-VstsMatchOptions'.
2020-11-18T09:16:44.3648197Z VERBOSE: Importing function 'Out-VstsDefault'.
2020-11-18T09:16:44.3648638Z VERBOSE: Importing function 'Select-VstsMatch'.
2020-11-18T09:16:44.3649100Z VERBOSE: Importing function 'Set-VstsTaskVariable'.
2020-11-18T09:16:44.3649585Z VERBOSE: Importing function 'Trace-VstsEnteringInvocation'.
2020-11-18T09:16:44.3650201Z VERBOSE: Importing function 'Trace-VstsLeavingInvocation'.
2020-11-18T09:16:44.3650594Z VERBOSE: Importing function 'Trace-VstsPath'.
2020-11-18T09:16:44.3650985Z VERBOSE: Importing function 'Write-VstsAddAttachment'.
2020-11-18T09:16:44.3651384Z VERBOSE: Importing function 'Write-VstsAddBuildTag'.
2020-11-18T09:16:44.3651790Z VERBOSE: Importing function 'Write-VstsAssociateArtifact'.
2020-11-18T09:16:44.3652630Z VERBOSE: Importing function 'Write-VstsLogDetail'.
2020-11-18T09:16:44.3653599Z VERBOSE: Importing function 'Write-VstsPrependPath'.
2020-11-18T09:16:44.3655695Z VERBOSE: Importing function 'Write-VstsSetEndpoint'.
2020-11-18T09:16:44.3656305Z VERBOSE: Importing function 'Write-VstsSetProgress'.
2020-11-18T09:16:44.3679213Z VERBOSE: Importing function 'Write-VstsSetResult'.
2020-11-18T09:16:44.3679750Z VERBOSE: Importing function 'Write-VstsSetSecret'.
2020-11-18T09:16:44.3680368Z VERBOSE: Importing function 'Write-VstsSetVariable'.
2020-11-18T09:16:44.3681001Z VERBOSE: Importing function 'Write-VstsTaskDebug'.
2020-11-18T09:16:44.3681490Z VERBOSE: Importing function 'Write-VstsTaskError'.
2020-11-18T09:16:44.3682002Z VERBOSE: Importing function 'Write-VstsTaskVerbose'.
2020-11-18T09:16:44.3682499Z VERBOSE: Importing function 'Write-VstsTaskWarning'.
2020-11-18T09:16:44.3683048Z VERBOSE: Importing function 'Write-VstsUpdateBuildNumber'.
2020-11-18T09:16:44.3683605Z VERBOSE: Importing function 'Write-VstsUpdateReleaseName'.
2020-11-18T09:16:44.3684140Z VERBOSE: Importing function 'Write-VstsUploadArtifact'.
2020-11-18T09:16:44.3684647Z VERBOSE: Importing function 'Write-VstsUploadBuildLog'.
2020-11-18T09:16:44.3685158Z VERBOSE: Importing function 'Write-VstsUploadFile'.
2020-11-18T09:16:44.3686536Z VERBOSE: Importing function 'Write-VstsUploadSummary'.
2020-11-18T09:16:44.3687280Z VERBOSE: Loading resource strings from: C:\TeamAgent3\_work\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\5.176.3\task.json
2020-11-18T09:16:44.4508195Z VERBOSE: Loaded 9 strings.
2020-11-18T09:16:44.4508690Z VERBOSE: SYSTEM_CULTURE: 'en-US'
2020-11-18T09:16:44.4509524Z VERBOSE: Loading resource strings from: C:\TeamAgent3\_work\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\5.176.3\Strings\resources.resjson\en-US\resources.resjson
2020-11-18T09:16:44.4569219Z VERBOSE: Loaded 9 strings.
2020-11-18T09:16:44.4754741Z VERBOSE: C:\Modules\azurerm_2.1.0 is not present in C:\Windows\ServiceProfiles\NetworkService\Documents\PowerShell\Modules;C:\Program Files\PowerShell\Modules;c:\program files\powershell\7\Modules;C:\Windows\ServiceProfiles\NetworkService\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules\;C:\Program Files (x86)\Microsoft SQL Server\130\Tools\PowerShell\Modules\;c:\Program Files\Microsoft Security Client\MpProvider\;C:\Program Files\Microsoft Monitoring Agent\Agent\AzureAutomation\7.3.837.0;C:\Program Files\Microsoft Monitoring Agent\Agent\PowerShell\
2020-11-18T09:16:44.5059494Z VERBOSE: C:\Modules\azure_2.1.0 is not present in C:\Windows\ServiceProfiles\NetworkService\Documents\PowerShell\Modules;C:\Program Files\PowerShell\Modules;c:\program files\powershell\7\Modules;C:\Windows\ServiceProfiles\NetworkService\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules\;C:\Program Files (x86)\Microsoft SQL Server\130\Tools\PowerShell\Modules\;c:\Program Files\Microsoft Security Client\MpProvider\;C:\Program Files\Microsoft Monitoring Agent\Agent\AzureAutomation\7.3.837.0;C:\Program Files\Microsoft Monitoring Agent\Agent\PowerShell\
2020-11-18T09:16:44.5064062Z VERBOSE: The updated value of the PSModulePath is: C:\Windows\ServiceProfiles\NetworkService\Documents\PowerShell\Modules;C:\Program Files\PowerShell\Modules;c:\program files\powershell\7\Modules;C:\Windows\ServiceProfiles\NetworkService\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules\;C:\Program Files (x86)\Microsoft SQL Server\130\Tools\PowerShell\Modules\;c:\Program Files\Microsoft Security Client\MpProvider\;C:\Program Files\Microsoft Monitoring Agent\Agent\AzureAutomation\7.3.837.0;C:\Program Files\Microsoft Monitoring Agent\Agent\PowerShell\
2020-11-18T09:16:44.5139667Z VERBOSE: Loading module from path 'C:\TeamAgent3\_work\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\5.176.3\ps_modules\VstsAzureHelpers_\VstsAzureHelpers_.psm1'.
2020-11-18T09:16:44.5384678Z VERBOSE: Loading resource strings from: C:\TeamAgent3\_work\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\5.176.3\ps_modules\VstsAzureHelpers_/module.json
2020-11-18T09:16:44.5700413Z VERBOSE: Loaded 13 strings.
2020-11-18T09:16:44.6189388Z VERBOSE: SYSTEM_CULTURE: 'en-US'
2020-11-18T09:16:44.6190214Z VERBOSE: Loading resource strings from: C:\TeamAgent3\_work\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\5.176.3\ps_modules\VstsAzureHelpers_\Strings\resources.resjson\en-US\resources.resjson
2020-11-18T09:16:44.6211735Z VERBOSE: Loaded 13 strings.
2020-11-18T09:16:44.6401427Z VERBOSE: Entering Get-VstsWebProxy.
2020-11-18T09:16:44.6566245Z VERBOSE: AGENT_VERSION: '2.175.2'
2020-11-18T09:16:44.6649197Z VERBOSE: AGENT_PROXYURL (empty)
2020-11-18T09:16:44.6977211Z VERBOSE: AGENT_PROXYUSERNAME (empty)
2020-11-18T09:16:44.7907716Z VERBOSE: AGENT_PROXYPASSWORD (empty)
2020-11-18T09:16:44.7962977Z VERBOSE: AGENT_PROXYBYPASSLIST (empty)
2020-11-18T09:16:44.8057979Z VERBOSE: Leaving Get-VstsWebProxy.
2020-11-18T09:16:44.8202650Z VERBOSE: Loading module from path 'C:\TeamAgent3\_work\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\5.176.3\ps_modules\TlsHelper_\TlsHelper_.psm1'.
2020-11-18T09:16:44.8344448Z VERBOSE: Loading resource strings from: C:\TeamAgent3\_work\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\5.176.3\ps_modules\TlsHelper_/module.json
2020-11-18T09:16:44.8555385Z VERBOSE: Loaded 3 strings.
2020-11-18T09:16:44.8567860Z VERBOSE: SYSTEM_CULTURE: 'en-US'
2020-11-18T09:16:44.8575142Z VERBOSE: Loading resource strings from: C:\TeamAgent3\_work\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\5.176.3\ps_modules\TlsHelper_\Strings\resources.resjson\en-US\resources.resjson
2020-11-18T09:16:44.8576072Z VERBOSE: Loaded 3 strings.
2020-11-18T09:16:44.8576742Z VERBOSE: Exporting function 'Add-Tls12InSession'.
2020-11-18T09:16:44.8577401Z VERBOSE: Exporting function 'Assert-TlsError'.
2020-11-18T09:16:44.8577838Z VERBOSE: Importing function 'Add-Tls12InSession'.
2020-11-18T09:16:44.8578287Z VERBOSE: Importing function 'Assert-TlsError'.
2020-11-18T09:16:44.9359478Z Added TLS 1.2 in session.
2020-11-18T09:16:45.0437633Z VERBOSE: Exporting function 'Initialize-Azure'.
2020-11-18T09:16:45.0438192Z VERBOSE: Exporting function 'CmdletHasMember'.
2020-11-18T09:16:45.0438676Z VERBOSE: Exporting function 'Remove-EndpointSecrets'.
2020-11-18T09:16:45.0439146Z VERBOSE: Exporting function 'Initialize-AzureRMModule'.
2020-11-18T09:16:45.0439631Z VERBOSE: Exporting function 'Initialize-AzModule'.
2020-11-18T09:16:45.0440111Z VERBOSE: Exporting function 'Disconnect-AzureAndClearContext'.
2020-11-18T09:16:45.0440683Z VERBOSE: Exporting function 'Update-PSModulePathForHostedAgentWithLatestModule'.
2020-11-18T09:16:45.0441203Z VERBOSE: Importing function 'CmdletHasMember'.
2020-11-18T09:16:45.0442274Z VERBOSE: Importing function 'Disconnect-AzureAndClearContext'.
2020-11-18T09:16:45.0442909Z VERBOSE: Importing function 'Initialize-AzModule'.
2020-11-18T09:16:45.0443410Z VERBOSE: Importing function 'Initialize-Azure'.
2020-11-18T09:16:45.0444027Z VERBOSE: Importing function 'Initialize-AzureRMModule'.
2020-11-18T09:16:45.0444825Z VERBOSE: Importing function 'Remove-EndpointSecrets'.
2020-11-18T09:16:45.0445564Z VERBOSE: Importing function 'Update-PSModulePathForHostedAgentWithLatestModule'.
2020-11-18T09:16:45.1259648Z VERBOSE: Entering Initialize-AzModule.
2020-11-18T09:16:45.1521994Z VERBOSE:  Endpoint: '@{Url=https://management.azure.com/; Data=; Auth=}'
2020-11-18T09:16:45.1527672Z VERBOSE:  azVersion: ''
2020-11-18T09:16:45.1535973Z VERBOSE: Env:PSModulePath: 'C:\Windows\ServiceProfiles\NetworkService\Documents\PowerShell\Modules;C:\Program Files\PowerShell\Modules;c:\program files\powershell\7\Modules;C:\Windows\ServiceProfiles\NetworkService\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules\;C:\Program Files (x86)\Microsoft SQL Server\130\Tools\PowerShell\Modules\;c:\Program Files\Microsoft Security Client\MpProvider\;C:\Program Files\Microsoft Monitoring Agent\Agent\AzureAutomation\7.3.837.0;C:\Program Files\Microsoft Monitoring Agent\Agent\PowerShell\'
2020-11-18T09:16:45.1613825Z VERBOSE: Entering Import-AzModule.
2020-11-18T09:16:45.1618416Z VERBOSE:  azVersion: ''
2020-11-18T09:16:45.1623202Z VERBOSE: Attempting to find the module 'Az.Accounts' from the module path.
2020-11-18T09:16:45.2227685Z VERBOSE: Populating RepositorySourceLocation property for module Az.Accounts.
2020-11-18T09:16:45.3423683Z ##[command]Import-Module -Name C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Az.Accounts.psd1 -Global
2020-11-18T09:16:45.3424725Z VERBOSE: Loading module from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Az.Accounts.psd1'.
2020-11-18T09:16:45.3481652Z VERBOSE: Loading 'Assembly' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Authentication.Abstractions.dll'.
2020-11-18T09:16:45.3482694Z VERBOSE: Loading 'Executable' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Authentication.Abstractions.dll'.
2020-11-18T09:16:45.3483900Z VERBOSE: Loading 'Assembly' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Authentication.dll'.
2020-11-18T09:16:45.3484796Z VERBOSE: Loading 'Executable' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Authentication.dll'.
2020-11-18T09:16:45.3486808Z VERBOSE: Loading 'Assembly' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Authenticators.dll'.
2020-11-18T09:16:45.3487758Z VERBOSE: Loading 'Executable' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Authenticators.dll'.
2020-11-18T09:16:45.3488713Z VERBOSE: Loading 'Assembly' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Authentication.ResourceManager.dll'.
2020-11-18T09:16:45.3489702Z VERBOSE: Loading 'Executable' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Authentication.ResourceManager.dll'.
2020-11-18T09:16:45.3490661Z VERBOSE: Loading 'Assembly' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Clients.Authorization.dll'.
2020-11-18T09:16:45.3491634Z VERBOSE: Loading 'Executable' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Clients.Authorization.dll'.
2020-11-18T09:16:45.3492569Z VERBOSE: Loading 'Assembly' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Clients.Compute.dll'.
2020-11-18T09:16:45.3493512Z VERBOSE: Loading 'Executable' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Clients.Compute.dll'.
2020-11-18T09:16:45.3494690Z VERBOSE: Loading 'Assembly' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Clients.Graph.Rbac.dll'.
2020-11-18T09:16:45.3495611Z VERBOSE: Loading 'Executable' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Clients.Graph.Rbac.dll'.
2020-11-18T09:16:45.3496473Z VERBOSE: Loading 'Assembly' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Clients.Monitor.dll'.
2020-11-18T09:16:45.3497603Z VERBOSE: Loading 'Executable' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Clients.Monitor.dll'.
2020-11-18T09:16:45.3498526Z VERBOSE: Loading 'Assembly' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Clients.Network.dll'.
2020-11-18T09:16:45.3499570Z VERBOSE: Loading 'Executable' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Clients.Network.dll'.
2020-11-18T09:16:45.3504725Z VERBOSE: Loading 'Assembly' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Clients.PolicyInsights.dll'.
2020-11-18T09:16:45.3509025Z VERBOSE: Loading 'Executable' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Clients.PolicyInsights.dll'.
2020-11-18T09:16:45.3521080Z VERBOSE: Loading 'Assembly' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Clients.ResourceManager.dll'.
2020-11-18T09:16:45.3525371Z VERBOSE: Loading 'Executable' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Clients.ResourceManager.dll'.
2020-11-18T09:16:45.3532480Z VERBOSE: Loading 'Assembly' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Common.dll'.
2020-11-18T09:16:45.3536730Z VERBOSE: Loading 'Executable' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Common.dll'.
2020-11-18T09:16:45.3591119Z VERBOSE: Loading 'Assembly' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Storage.dll'.
2020-11-18T09:16:45.3592290Z VERBOSE: Loading 'Executable' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Storage.dll'.
2020-11-18T09:16:45.3594768Z VERBOSE: Loading 'Assembly' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Clients.Storage.Management.dll'.
2020-11-18T09:16:45.3595805Z VERBOSE: Loading 'Executable' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Clients.Storage.Management.dll'.
2020-11-18T09:16:45.3596743Z VERBOSE: Loading 'Assembly' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Clients.KeyVault.dll'.
2020-11-18T09:16:45.3597768Z VERBOSE: Loading 'Executable' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Clients.KeyVault.dll'.
2020-11-18T09:16:45.3598627Z VERBOSE: Loading 'Assembly' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Clients.Websites.dll'.
2020-11-18T09:16:45.3619610Z VERBOSE: Loading 'Executable' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Clients.Websites.dll'.
2020-11-18T09:16:45.3620432Z VERBOSE: Loading 'Assembly' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Hyak.Common.dll'.
2020-11-18T09:16:45.3727995Z VERBOSE: Loading 'Executable' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Hyak.Common.dll'.
2020-11-18T09:16:45.3768602Z VERBOSE: Loading 'Assembly' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.ApplicationInsights.dll'.
2020-11-18T09:16:45.3893966Z VERBOSE: Loading 'Executable' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.ApplicationInsights.dll'.
2020-11-18T09:16:45.3895569Z VERBOSE: Loading 'Assembly' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.Common.dll'.
2020-11-18T09:16:45.3896399Z VERBOSE: Loading 'Executable' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.Common.dll'.
2020-11-18T09:16:45.3897276Z VERBOSE: Loading 'Assembly' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Rest.ClientRuntime.dll'.
2020-11-18T09:16:45.3898092Z VERBOSE: Loading 'Executable' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Rest.ClientRuntime.dll'.
2020-11-18T09:16:45.3898972Z VERBOSE: Loading 'Assembly' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Rest.ClientRuntime.Azure.dll'.
2020-11-18T09:16:45.3899807Z VERBOSE: Loading 'Executable' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Rest.ClientRuntime.Azure.dll'.
2020-11-18T09:16:45.3914075Z VERBOSE: Loading 'Assembly' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.WindowsAzure.Storage.dll'.
2020-11-18T09:16:45.3932418Z VERBOSE: Loading 'Executable' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.WindowsAzure.Storage.dll'.
2020-11-18T09:16:45.3936466Z VERBOSE: Loading 'Assembly' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.WindowsAzure.Storage.DataMovement.dll'.
2020-11-18T09:16:45.3937796Z VERBOSE: Loading 'Executable' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.WindowsAzure.Storage.DataMovement.dll'.
2020-11-18T09:16:45.3960815Z VERBOSE: Loading 'Assembly' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Clients.Aks.dll'.
2020-11-18T09:16:45.3961721Z VERBOSE: Loading 'Executable' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Clients.Aks.dll'.
2020-11-18T09:16:45.3962652Z VERBOSE: Loading 'Assembly' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Strategies.dll'.
2020-11-18T09:16:45.4720949Z VERBOSE: Loading 'Executable' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Strategies.dll'.
2020-11-18T09:16:45.4722655Z VERBOSE: Loading 'FormatsToProcess' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Accounts.format.ps1xml'.
2020-11-18T09:16:45.4724583Z VERBOSE: Loading 'FormatsToProcess' from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Accounts.generated.format.ps1xml'.
2020-11-18T09:16:45.4725726Z VERBOSE: Populating RepositorySourceLocation property for module Az.Accounts.
2020-11-18T09:16:45.5317028Z VERBOSE: Loading module from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Az.Accounts.psm1'.
2020-11-18T09:16:45.8099507Z VERBOSE: Loading module from path 'C:\Program Files\PowerShell\Modules\Az.Accounts\2.1.2\Microsoft.Azure.PowerShell.Cmdlets.Accounts.dll'.
2020-11-18T09:16:46.1702863Z VERBOSE: Importing cmdlet 'Register-AzModule'.
2020-11-18T09:16:46.5023156Z VERBOSE: Importing cmdlet 'Connect-AzAccount'.
2020-11-18T09:16:46.5027269Z VERBOSE: Importing cmdlet 'Disconnect-AzAccount'.
2020-11-18T09:16:46.5031952Z VERBOSE: Importing cmdlet 'Get-AzContext'.
2020-11-18T09:16:46.5035367Z VERBOSE: Importing cmdlet 'Import-AzContext'.
2020-11-18T09:16:46.5040383Z VERBOSE: Importing cmdlet 'Save-AzContext'.
2020-11-18T09:16:46.5043211Z VERBOSE: Importing cmdlet 'Set-AzContext'.
2020-11-18T09:16:46.5046116Z VERBOSE: Importing cmdlet 'Disable-AzDataCollection'.
2020-11-18T09:16:46.5049117Z VERBOSE: Importing cmdlet 'Enable-AzDataCollection'.
2020-11-18T09:16:46.5052047Z VERBOSE: Importing cmdlet 'Add-AzEnvironment'.
2020-11-18T09:16:46.5055031Z VERBOSE: Importing cmdlet 'Get-AzEnvironment'.
2020-11-18T09:16:46.5057569Z VERBOSE: Importing cmdlet 'Remove-AzEnvironment'.
2020-11-18T09:16:46.5060104Z VERBOSE: Importing cmdlet 'Set-AzEnvironment'.
2020-11-18T09:16:46.5062904Z VERBOSE: Importing cmdlet 'Send-Feedback'.
2020-11-18T09:16:46.5065501Z VERBOSE: Importing cmdlet 'Get-AzSubscription'.
2020-11-18T09:16:46.5068039Z VERBOSE: Importing cmdlet 'Get-AzTenant'.
2020-11-18T09:16:46.5070560Z VERBOSE: Importing cmdlet 'Uninstall-AzureRm'.
2020-11-18T09:16:46.5073142Z VERBOSE: Importing cmdlet 'Invoke-AzRestMethod'.
2020-11-18T09:16:46.5075587Z VERBOSE: Importing cmdlet 'Resolve-AzError'.
2020-11-18T09:16:46.5078494Z VERBOSE: Importing cmdlet 'Clear-AzDefault'.
2020-11-18T09:16:46.5081473Z VERBOSE: Importing cmdlet 'Get-AzDefault'.
2020-11-18T09:16:46.5084180Z VERBOSE: Importing cmdlet 'Set-AzDefault'.
2020-11-18T09:16:46.5086648Z VERBOSE: Importing cmdlet 'Disable-AzureRmAlias'.
2020-11-18T09:16:46.5089611Z VERBOSE: Importing cmdlet 'Enable-AzureRmAlias'.
2020-11-18T09:16:46.5093052Z VERBOSE: Importing cmdlet 'Disable-AzContextAutosave'.
2020-11-18T09:16:46.5095926Z VERBOSE: Importing cmdlet 'Enable-AzContextAutosave'.
2020-11-18T09:16:46.5098551Z VERBOSE: Importing cmdlet 'Get-AzContextAutosaveSetting'.
2020-11-18T09:16:46.5101147Z VERBOSE: Importing cmdlet 'Clear-AzContext'.
2020-11-18T09:16:46.5103624Z VERBOSE: Importing cmdlet 'Remove-AzContext'.
2020-11-18T09:16:46.5106154Z VERBOSE: Importing cmdlet 'Rename-AzContext'.
2020-11-18T09:16:46.5108527Z VERBOSE: Importing cmdlet 'Select-AzContext'.
2020-11-18T09:16:46.5110725Z VERBOSE: Importing alias 'Login-AzAccount'.
2020-11-18T09:16:46.5113136Z VERBOSE: Importing alias 'Login-AzureRmAccount'.
2020-11-18T09:16:46.5115590Z VERBOSE: Importing alias 'Add-AzAccount'.
2020-11-18T09:16:46.5118048Z VERBOSE: Importing alias 'Logout-AzAccount'.
2020-11-18T09:16:46.5120675Z VERBOSE: Importing alias 'Logout-AzureRmAccount'.
2020-11-18T09:16:46.5123237Z VERBOSE: Importing alias 'Remove-AzAccount'.
2020-11-18T09:16:46.5125941Z VERBOSE: Importing alias 'Save-AzProfile'.
2020-11-18T09:16:46.5128551Z VERBOSE: Importing alias 'Select-AzSubscription'.
2020-11-18T09:16:46.5131280Z VERBOSE: Importing alias 'Get-AzureRmDomain'.
2020-11-18T09:16:46.5133772Z VERBOSE: Importing alias 'Get-AzDomain'.
2020-11-18T09:16:46.5136320Z VERBOSE: Importing alias 'Invoke-AzRest'.
2020-11-18T09:16:46.5138951Z VERBOSE: Importing alias 'Resolve-Error'.
2020-11-18T09:16:46.5359799Z VERBOSE: Exporting function 'Test-DotNet'.
2020-11-18T09:16:46.5362700Z VERBOSE: Exporting function 'Write-InstallationCheckToFile'.
2020-11-18T09:16:46.5365772Z VERBOSE: Exporting cmdlet 'Register-AzModule'.
2020-11-18T09:16:46.5368483Z VERBOSE: Exporting cmdlet 'Connect-AzAccount'.
2020-11-18T09:16:46.5371224Z VERBOSE: Exporting cmdlet 'Disconnect-AzAccount'.
2020-11-18T09:16:46.5373961Z VERBOSE: Exporting cmdlet 'Get-AzContext'.
2020-11-18T09:16:46.5376618Z VERBOSE: Exporting cmdlet 'Import-AzContext'.
2020-11-18T09:16:46.5379267Z VERBOSE: Exporting cmdlet 'Save-AzContext'.
2020-11-18T09:16:46.5382009Z VERBOSE: Exporting cmdlet 'Set-AzContext'.
2020-11-18T09:16:46.5384752Z VERBOSE: Exporting cmdlet 'Disable-AzDataCollection'.
2020-11-18T09:16:46.5387462Z VERBOSE: Exporting cmdlet 'Enable-AzDataCollection'.
2020-11-18T09:16:46.5390175Z VERBOSE: Exporting cmdlet 'Add-AzEnvironment'.
2020-11-18T09:16:46.5392841Z VERBOSE: Exporting cmdlet 'Get-AzEnvironment'.
2020-11-18T09:16:46.5395533Z VERBOSE: Exporting cmdlet 'Remove-AzEnvironment'.
2020-11-18T09:16:46.5398292Z VERBOSE: Exporting cmdlet 'Set-AzEnvironment'.
2020-11-18T09:16:46.5400937Z VERBOSE: Exporting cmdlet 'Send-Feedback'.
2020-11-18T09:16:46.5403697Z VERBOSE: Exporting cmdlet 'Get-AzSubscription'.
2020-11-18T09:16:46.5406313Z VERBOSE: Exporting cmdlet 'Get-AzTenant'.
2020-11-18T09:16:46.5408888Z VERBOSE: Exporting cmdlet 'Uninstall-AzureRm'.
2020-11-18T09:16:46.5411572Z VERBOSE: Exporting cmdlet 'Invoke-AzRestMethod'.
2020-11-18T09:16:46.5414275Z VERBOSE: Exporting cmdlet 'Resolve-AzError'.
2020-11-18T09:16:46.5416913Z VERBOSE: Exporting cmdlet 'Clear-AzDefault'.
2020-11-18T09:16:46.5419625Z VERBOSE: Exporting cmdlet 'Get-AzDefault'.
2020-11-18T09:16:46.5422500Z VERBOSE: Exporting cmdlet 'Set-AzDefault'.
2020-11-18T09:16:46.5425234Z VERBOSE: Exporting cmdlet 'Disable-AzureRmAlias'.
2020-11-18T09:16:46.5427997Z VERBOSE: Exporting cmdlet 'Enable-AzureRmAlias'.
2020-11-18T09:16:46.5430870Z VERBOSE: Exporting cmdlet 'Disable-AzContextAutosave'.
2020-11-18T09:16:46.5433558Z VERBOSE: Exporting cmdlet 'Enable-AzContextAutosave'.
2020-11-18T09:16:46.5436247Z VERBOSE: Exporting cmdlet 'Get-AzContextAutosaveSetting'.
2020-11-18T09:16:46.5438894Z VERBOSE: Exporting cmdlet 'Clear-AzContext'.
2020-11-18T09:16:46.5441453Z VERBOSE: Exporting cmdlet 'Remove-AzContext'.
2020-11-18T09:16:46.5444652Z VERBOSE: Exporting cmdlet 'Rename-AzContext'.
2020-11-18T09:16:46.5447487Z VERBOSE: Exporting cmdlet 'Select-AzContext'.
2020-11-18T09:16:46.5450433Z VERBOSE: Exporting alias 'Login-AzAccount'.
2020-11-18T09:16:46.5453112Z VERBOSE: Exporting alias 'Login-AzureRmAccount'.
2020-11-18T09:16:46.5455813Z VERBOSE: Exporting alias 'Add-AzAccount'.
2020-11-18T09:16:46.5458522Z VERBOSE: Exporting alias 'Logout-AzAccount'.
2020-11-18T09:16:46.5461189Z VERBOSE: Exporting alias 'Logout-AzureRmAccount'.
2020-11-18T09:16:46.5463918Z VERBOSE: Exporting alias 'Remove-AzAccount'.
2020-11-18T09:16:46.5466569Z VERBOSE: Exporting alias 'Save-AzProfile'.
2020-11-18T09:16:46.5469316Z VERBOSE: Exporting alias 'Select-AzSubscription'.
2020-11-18T09:16:46.5471943Z VERBOSE: Exporting alias 'Get-AzureRmDomain'.
2020-11-18T09:16:46.5474560Z VERBOSE: Exporting alias 'Get-AzDomain'.
2020-11-18T09:16:46.5477090Z VERBOSE: Exporting alias 'Invoke-AzRest'.
2020-11-18T09:16:46.5479651Z VERBOSE: Exporting alias 'Resolve-Error'.
2020-11-18T09:16:46.5485824Z VERBOSE: Importing cmdlet 'Add-AzEnvironment'.
2020-11-18T09:16:46.5490781Z VERBOSE: Importing cmdlet 'Clear-AzContext'.
2020-11-18T09:16:46.5496501Z VERBOSE: Importing cmdlet 'Clear-AzDefault'.
2020-11-18T09:16:46.5507649Z VERBOSE: Importing cmdlet 'Connect-AzAccount'.
2020-11-18T09:16:46.5510292Z VERBOSE: Importing cmdlet 'Disable-AzContextAutosave'.
2020-11-18T09:16:46.5512996Z VERBOSE: Importing cmdlet 'Disable-AzDataCollection'.
2020-11-18T09:16:46.5516722Z VERBOSE: Importing cmdlet 'Disable-AzureRmAlias'.
2020-11-18T09:16:46.5519353Z VERBOSE: Importing cmdlet 'Disconnect-AzAccount'.
2020-11-18T09:16:46.5523230Z VERBOSE: Importing cmdlet 'Enable-AzContextAutosave'.
2020-11-18T09:16:46.5526341Z VERBOSE: Importing cmdlet 'Enable-AzDataCollection'.
2020-11-18T09:16:46.5529095Z VERBOSE: Importing cmdlet 'Enable-AzureRmAlias'.
2020-11-18T09:16:46.5531711Z VERBOSE: Importing cmdlet 'Get-AzContext'.
2020-11-18T09:16:46.5534392Z VERBOSE: Importing cmdlet 'Get-AzContextAutosaveSetting'.
2020-11-18T09:16:46.5536801Z VERBOSE: Importing cmdlet 'Get-AzDefault'.
2020-11-18T09:16:46.5539413Z VERBOSE: Importing cmdlet 'Get-AzEnvironment'.
2020-11-18T09:16:46.5541484Z VERBOSE: Importing cmdlet 'Get-AzSubscription'.
2020-11-18T09:16:46.5543481Z VERBOSE: Importing cmdlet 'Get-AzTenant'.
2020-11-18T09:16:46.5558499Z VERBOSE: Importing cmdlet 'Import-AzContext'.
2020-11-18T09:16:46.5571327Z VERBOSE: Importing cmdlet 'Invoke-AzRestMethod'.
2020-11-18T09:16:46.5573963Z VERBOSE: Importing cmdlet 'Register-AzModule'.
2020-11-18T09:16:46.5576625Z VERBOSE: Importing cmdlet 'Remove-AzContext'.
2020-11-18T09:16:46.5579267Z VERBOSE: Importing cmdlet 'Remove-AzEnvironment'.
2020-11-18T09:16:46.5581952Z VERBOSE: Importing cmdlet 'Rename-AzContext'.
2020-11-18T09:16:46.5584689Z VERBOSE: Importing cmdlet 'Resolve-AzError'.
2020-11-18T09:16:46.5587181Z VERBOSE: Importing cmdlet 'Save-AzContext'.
2020-11-18T09:16:46.5589995Z VERBOSE: Importing cmdlet 'Select-AzContext'.
2020-11-18T09:16:46.5593778Z VERBOSE: Importing cmdlet 'Send-Feedback'.
2020-11-18T09:16:46.5596458Z VERBOSE: Importing cmdlet 'Set-AzContext'.
2020-11-18T09:16:46.5625836Z VERBOSE: Importing cmdlet 'Set-AzDefault'.
2020-11-18T09:16:46.5649813Z VERBOSE: Importing cmdlet 'Set-AzEnvironment'.
2020-11-18T09:16:46.5654359Z VERBOSE: Importing cmdlet 'Uninstall-AzureRm'.
2020-11-18T09:16:46.5658049Z VERBOSE: Importing alias 'Add-AzAccount'.
2020-11-18T09:16:46.5661251Z VERBOSE: Importing alias 'Get-AzDomain'.
2020-11-18T09:16:46.5669020Z VERBOSE: Importing alias 'Invoke-AzRest'.
2020-11-18T09:16:46.5674380Z VERBOSE: Importing alias 'Login-AzAccount'.
2020-11-18T09:16:46.5677075Z VERBOSE: Importing alias 'Logout-AzAccount'.
2020-11-18T09:16:46.5679861Z VERBOSE: Importing alias 'Remove-AzAccount'.
2020-11-18T09:16:46.5682498Z VERBOSE: Importing alias 'Resolve-Error'.
2020-11-18T09:16:46.5685202Z VERBOSE: Importing alias 'Save-AzProfile'.
2020-11-18T09:16:46.5689337Z VERBOSE: Importing alias 'Select-AzSubscription'.
2020-11-18T09:16:46.5710418Z VERBOSE: Imported module version: 2.1.2
2020-11-18T09:16:46.5748276Z VERBOSE: Leaving Import-AzModule.
2020-11-18T09:16:46.5752947Z VERBOSE: Initializing Az Module.
2020-11-18T09:16:46.5830039Z VERBOSE: AZURE_HTTP_USER_AGENT: 'VSTS_a9b640d7-e674-42a9-b281-19d6a9bb3ce7_build_1105_0'
2020-11-18T09:16:46.5846217Z VERBOSE: Entering Set-UserAgent_Core.
2020-11-18T09:16:46.5850625Z VERBOSE:  UserAgent: 'VSTS_a9b640d7-e674-42a9-b281-19d6a9bb3ce7_build_1105_0'
2020-11-18T09:16:46.5874365Z VERBOSE: Leaving Set-UserAgent_Core.
2020-11-18T09:16:46.5879046Z ##[command]Clear-AzContext -Scope CurrentUser -Force -ErrorAction SilentlyContinue
2020-11-18T09:16:46.6248277Z VERBOSE: Populating RepositorySourceLocation property for module Az.
2020-11-18T09:16:47.5334264Z ##[command]Clear-AzContext -Scope Process
2020-11-18T09:16:48.2616306Z ##[command]Connect-AzAccount -ServicePrincipal -Tenant *** -Credential System.Management.Automation.PSCredential -Environment AzureCloud @processScope
2020-11-18T09:16:50.0353186Z ##[command] Set-AzContext -SubscriptionId subscriptionguid -TenantId ***
2020-11-18T09:16:50.5992784Z VERBOSE: Leaving Initialize-AzModule.
2020-11-18T09:16:50.6075705Z ##[debug]Error record:
2020-11-18T09:16:50.7331833Z ##[debug]
2020-11-18T09:16:50.7334479Z ##[debug].: C:\TeamAgent3\_work\_temp\34e0097d-a5be-4b55-bc2c-48492db2d299.ps1:38
2020-11-18T09:16:50.7335476Z ##[debug]Line |
2020-11-18T09:16:50.7345466Z ##[debug]  38 |  . 'C:\TeamAgent3\_work\1639\s'
2020-11-18T09:16:50.7346132Z ##[debug]     |    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2020-11-18T09:16:50.7588377Z ##[debug]     | The term 'C:\TeamAgent3\_work\1639\s' is not recognized as a name of a
2020-11-18T09:16:50.7589552Z ##[debug]     | cmdlet, function, script file, or executable program. Check the spelling
2020-11-18T09:16:50.7590866Z ##[debug]     | of the name, or if a path was included, verify that the path is correct
2020-11-18T09:16:50.7591760Z ##[debug]     | and try again.
2020-11-18T09:16:50.7592418Z ##[debug]
2020-11-18T09:16:50.7593026Z ##[debug]Script stack trace:
2020-11-18T09:16:50.7593964Z ##[debug]at <ScriptBlock>, C:\TeamAgent3\_work\_temp\34e0097d-a5be-4b55-bc2c-48492db2d299.ps1: line 38
2020-11-18T09:16:50.7594854Z ##[debug]at <ScriptBlock>, <No file>: line 1
2020-11-18T09:16:50.7595575Z ##[debug]Exception:
2020-11-18T09:16:50.7597624Z ##[debug]System.Management.Automation.ParentContainsErrorRecordException: The term 'C:\TeamAgent3\_work\1639\s' is not recognized as a name of a cmdlet, function, script file, or executable program.
2020-11-18T09:16:50.7598961Z ##[debug]Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
2020-11-18T09:16:50.7644948Z ##[error]The term 'C:\TeamAgent3\_work\1639\s' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
2020-11-18T09:16:50.7729634Z ##[debug]Processed: ##vso[task.logissue type=error]The term 'C:\TeamAgent3\_work\1639\s' is not recognized as a name of a cmdlet, function, script file, or executable program.%0D%0ACheck the spelling of the name, or if a path was included, verify that the path is correct and try again.
2020-11-18T09:16:50.8501756Z ##[debug]Exit code: 1
2020-11-18T09:16:50.8502349Z ##[debug]Leaving Invoke-VstsTool.
2020-11-18T09:16:50.9061339Z ##[error]PowerShell exited with code '1'.
2020-11-18T09:16:50.9064123Z ##[debug]Processed: ##vso[task.logissue type=error]PowerShell exited with code '1'.
2020-11-18T09:16:50.9283101Z ##[debug]Processed: ##vso[task.complete result=Failed]Error detected
2020-11-18T09:16:51.1099197Z ##[debug]Loading module from path 'C:\TeamAgent3\_work\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\5.176.3\ps_modules\VstsAzureHelpers_\VstsAzureHelpers_.psm1'.
2020-11-18T09:16:51.1129286Z ##[debug]$OVERRIDING $global:DebugPreference from 'Continue' to 'SilentlyContinue'.
2020-11-18T09:16:51.1325528Z ##[debug]Loading resource strings from: C:\TeamAgent3\_work\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\5.176.3\ps_modules\VstsAzureHelpers_/module.json
2020-11-18T09:16:51.1427537Z ##[debug]Loaded 13 strings.
2020-11-18T09:16:51.1543250Z ##[debug]SYSTEM_CULTURE: 'en-US'
2020-11-18T09:16:51.1544385Z ##[debug]Loading resource strings from: C:\TeamAgent3\_work\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\5.176.3\ps_modules\VstsAzureHelpers_\Strings\resources.resjson\en-US\resources.resjson
2020-11-18T09:16:51.2384274Z ##[debug]Loaded 13 strings.
2020-11-18T09:16:51.2384983Z ##[debug]Entering Get-VstsWebProxy.
2020-11-18T09:16:51.2602890Z ##[debug]AGENT_VERSION: '2.175.2'
2020-11-18T09:16:51.2624408Z ##[debug]AGENT_PROXYURL (empty)
2020-11-18T09:16:51.2626876Z ##[debug]AGENT_PROXYUSERNAME (empty)
2020-11-18T09:16:51.2627686Z ##[debug]AGENT_PROXYPASSWORD (empty)
2020-11-18T09:16:51.2689060Z ##[debug]AGENT_PROXYBYPASSLIST (empty)
2020-11-18T09:16:51.2827914Z ##[debug]Leaving Get-VstsWebProxy.
2020-11-18T09:16:51.2929228Z ##[debug]Loading module from path 'C:\TeamAgent3\_work\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\5.176.3\ps_modules\TlsHelper_\TlsHelper_.psm1'.
2020-11-18T09:16:51.3467036Z ##[debug]Loading resource strings from: C:\TeamAgent3\_work\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\5.176.3\ps_modules\TlsHelper_/module.json
2020-11-18T09:16:51.3468068Z ##[debug]Loaded 3 strings.
2020-11-18T09:16:51.3469186Z ##[debug]SYSTEM_CULTURE: 'en-US'
2020-11-18T09:16:51.3470255Z ##[debug]Loading resource strings from: C:\TeamAgent3\_work\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\5.176.3\ps_modules\TlsHelper_\Strings\resources.resjson\en-US\resources.resjson
2020-11-18T09:16:51.3471955Z ##[debug]Loaded 3 strings.
2020-11-18T09:16:51.3508305Z ##[debug]Exporting function 'Add-Tls12InSession'.
2020-11-18T09:16:51.3613914Z ##[debug]Exporting function 'Assert-TlsError'.
2020-11-18T09:16:51.3768491Z ##[debug]Importing function 'Add-Tls12InSession'.
2020-11-18T09:16:51.3769177Z ##[debug]Importing function 'Assert-TlsError'.
2020-11-18T09:16:51.4061597Z ##[debug]TLS 1.2 already present in session.
2020-11-18T09:16:51.4629134Z ##[debug]Exporting function 'Initialize-Azure'.
2020-11-18T09:16:51.4673677Z ##[debug]Exporting function 'CmdletHasMember'.
2020-11-18T09:16:51.4865485Z ##[debug]Exporting function 'Remove-EndpointSecrets'.
2020-11-18T09:16:51.4866151Z ##[debug]Exporting function 'Initialize-AzureRMModule'.
2020-11-18T09:16:51.4866842Z ##[debug]Exporting function 'Initialize-AzModule'.
2020-11-18T09:16:51.4867548Z ##[debug]Exporting function 'Disconnect-AzureAndClearContext'.
2020-11-18T09:16:51.4868772Z ##[debug]Exporting function 'Update-PSModulePathForHostedAgentWithLatestModule'.
2020-11-18T09:16:51.4924543Z ##[debug]Importing function 'CmdletHasMember'.
2020-11-18T09:16:51.4991500Z ##[debug]Importing function 'Disconnect-AzureAndClearContext'.
2020-11-18T09:16:51.4992286Z ##[debug]Importing function 'Initialize-AzModule'.
2020-11-18T09:16:51.5012355Z ##[debug]Importing function 'Initialize-Azure'.
2020-11-18T09:16:51.5054826Z ##[debug]Importing function 'Initialize-AzureRMModule'.
2020-11-18T09:16:51.5271709Z ##[debug]Importing function 'Remove-EndpointSecrets'.
2020-11-18T09:16:51.5272392Z ##[debug]Importing function 'Update-PSModulePathForHostedAgentWithLatestModule'.
2020-11-18T09:16:51.5306103Z ##[debug]Trying to disconnect from Azure and clear context at process scope
2020-11-18T09:16:51.9573482Z VERBOSE: Loading module from path 
2020-11-18T09:16:51.9574480Z 'C:\Windows\ServiceProfiles\NetworkService\Documents\WindowsPowerShell\Modules\
2020-11-18T09:16:51.9575676Z AzureRM.profile\5.7.0\Microsoft.Azure.Commands.Profile.dll'.
2020-11-18T09:16:52.2412593Z VERBOSE: Importing cmdlet 'Disconnect-AzureRmAccount'.
2020-11-18T09:16:52.2416363Z VERBOSE: Importing cmdlet 'Disable-AzureRmDataCollection'.
2020-11-18T09:16:52.2419980Z VERBOSE: Importing cmdlet 'Enable-AzureRmDataCollection'.
2020-11-18T09:16:52.2423576Z VERBOSE: Importing cmdlet 'Remove-AzureRmEnvironment'.
2020-11-18T09:16:52.2427426Z VERBOSE: Importing cmdlet 'Get-AzureRmEnvironment'.
2020-11-18T09:16:52.2430946Z VERBOSE: Importing cmdlet 'Set-AzureRmEnvironment'.
2020-11-18T09:16:52.2434468Z VERBOSE: Importing cmdlet 'Add-AzureRmEnvironment'.
2020-11-18T09:16:52.2437997Z VERBOSE: Importing cmdlet 'Send-Feedback'.
2020-11-18T09:16:52.2441559Z VERBOSE: Importing cmdlet 'Get-AzureRmSubscription'.
2020-11-18T09:16:52.2445303Z VERBOSE: Importing cmdlet 'Connect-AzureRmAccount'.
2020-11-18T09:16:52.2448894Z VERBOSE: Importing cmdlet 'Get-AzureRmContext'.
2020-11-18T09:16:52.2452428Z VERBOSE: Importing cmdlet 'Set-AzureRmContext'.
2020-11-18T09:16:52.2456080Z VERBOSE: Importing cmdlet 'Import-AzureRmContext'.
2020-11-18T09:16:52.2459684Z VERBOSE: Importing cmdlet 'Save-AzureRmContext'.
2020-11-18T09:16:52.2463385Z VERBOSE: Importing cmdlet 'Get-AzureRmTenant'.
2020-11-18T09:16:52.2466950Z VERBOSE: Importing cmdlet 'Resolve-AzureRmError'.
2020-11-18T09:16:52.2470638Z VERBOSE: Importing cmdlet 'Clear-AzureRmDefault'.
2020-11-18T09:16:52.2474311Z VERBOSE: Importing cmdlet 'Get-AzureRmDefault'.
2020-11-18T09:16:52.2478006Z VERBOSE: Importing cmdlet 'Set-AzureRmDefault'.
2020-11-18T09:16:52.2481818Z VERBOSE: Importing cmdlet 'Disable-AzureRmContextAutosave'.
2020-11-18T09:16:52.2485619Z VERBOSE: Importing cmdlet 'Get-AzureRmContextAutosaveSetting'.
2020-11-18T09:16:52.2489379Z VERBOSE: Importing cmdlet 'Enable-AzureRmContextAutosave'.
2020-11-18T09:16:52.2493162Z VERBOSE: Importing cmdlet 'Clear-AzureRmContext'.
2020-11-18T09:16:52.2496786Z VERBOSE: Importing cmdlet 'Remove-AzureRmContext'.
2020-11-18T09:16:52.2500553Z VERBOSE: Importing cmdlet 'Rename-AzureRmContext'.
2020-11-18T09:16:52.2504603Z VERBOSE: Importing cmdlet 'Select-AzureRmContext'.
2020-11-18T09:16:52.2508218Z VERBOSE: Importing alias 'Logout-AzAccount'.
2020-11-18T09:16:52.2511780Z VERBOSE: Importing alias 'Logout-AzureRmAccount'.
2020-11-18T09:16:52.2515370Z VERBOSE: Importing alias 'Remove-AzureRmAccount'.
2020-11-18T09:16:52.2518995Z VERBOSE: Importing alias 'Login-AzAccount'.
2020-11-18T09:16:52.2522653Z VERBOSE: Importing alias 'Login-AzureRmAccount'.
2020-11-18T09:16:52.2527210Z VERBOSE: Importing alias 'Add-AzureRmAccount'.
2020-11-18T09:16:52.2532565Z VERBOSE: Importing alias 'Select-AzureRmSubscription'.
2020-11-18T09:16:52.2536321Z VERBOSE: Importing alias 'Save-AzureRmProfile'.
2020-11-18T09:16:52.2539952Z VERBOSE: Importing alias 'Get-AzureRmDomain'.
2020-11-18T09:16:52.2575345Z VERBOSE: Importing alias 'Resolve-Error'.
2020-11-18T09:16:52.2667253Z ##[command]Disconnect-AzureRmAccount -Scope Process -ErrorAction Stop
2020-11-18T09:16:52.3327590Z ##[debug]Unable to disconnect and clear context: Run Connect-AzureRmAccount to login.
2020-11-18T09:16:52.3335799Z ##[warning]Run Connect-AzureRmAccount to login.
2020-11-18T09:16:52.3338403Z ##[debug]Processed: ##vso[task.logissue type=warning;]Run Connect-AzureRmAccount to login.
2020-11-18T09:16:52.3635254Z ##[section]Finishing: Execute Azure PowerShell
20shivangi commented 3 years ago

@Jeej From the logs of AzurePowerShellV5, it can be seen that module is correctly loaded from path of PowerShell core module only, which is what was expected. Please let us know if you are still facing some issue

20shivangi commented 3 years ago

@Jeej Any update here ?

Also, from the logs that you attached first, I did not find path 'C:\Program Files\PowerShell\Modules' in $env:PSModulePath (Env:PSModulePath: 'C:\Windows\ServiceProfiles\NetworkService\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules\;C:\Program Files (x86)\Microsoft SQL Server\130\Tools\PowerShell\Modules\;c:\Program Files\Microsoft Security Client\MpProvider\;C:\Program Files\Microsoft Monitoring Agent\Agent\AzureAutomation\7.3.837.0;C:\Program Files\Microsoft Monitoring Agent\Agent\PowerShell\' )

and you have selected pwsh to true due to which task is failing

20shivangi commented 3 years ago

@Jeej Please let us know if you got unblocked

Jeej commented 3 years ago

@20shivangi I have missed your message before, I am unfortunately quit busy... I will see if I can execute another try today.

Like I put in the initial message, I have on the VM AzureRM and Azure Powershell. AzureRM is installed on the system and is used in the "old" powershell, the Windows Powershell. The Azure Powershell is installed in Powershell Core (7) and only there to avoid conflicts. This is why I selected pwsh, because the script is using Azure Powershell and not AzureRM, so it should run in Powershell core. Also you can see in my initial message that "Az.Accounts" is available in powershell core. The task is not failing because I selected pwsh, but because this AzurePowerShell tries to initialize Azure Powershell in the Windows Powershell and there it is not available.

20shivangi commented 3 years ago

@Jeej I got your point. But with AzurePowerShellV5, initialization and script execution happens in same session. So, wanted to know if you are facing this issue with V5 version also

20shivangi commented 3 years ago

@Jeej Let us know if you still are facing issue with V5 version

Jeej commented 3 years ago

@20shivangi I have tried it now with V5 and yes it is working. The error was in the script, because I was using inline I had to set ScriptType to inlineScript. You can see above that it was missing in the script that I run.

20shivangi commented 3 years ago

@Jeej It is great that you got unblocked using V5 version of task. Please use the latest version of task i.e. V5. I am closing this issue. Please feel free to re-open it if you face any issue. :)