title: Azure DevOps build pipeline with hosted agent failing
body: <p>I am pretty new to Azure and TFS and related. So please excuse me if I mix up the terms here.</p>
  
  <p>I am testing the capabilities of Microsoft Team Foundation Server with an on-premise installation. I am not the admin of the server itself, I have admin access to one of the projects inside. </p>
  
  <p>I have a git repo with some python code in this project and I am trying to set up CI build pipeline for this. I am also manually configuring an agent to run this build pipeline. For the timebeing, I am configuring the windows machine that I am working on to run as an agent. I was able to set it up to listen for jobs and also it picks up the job when submitted from the TFS server. (I am running the agent from a cmd.exe window)
  However, I couldn't get it do even the simplest of command line tasks as part of the build pipeline.</p>
  
  <p>Below is the output of <code>where python</code>:</p>
  
  <pre><code>2019-08-27T14:41:15.1614046Z ##[section]Starting: Find python version
  2019-08-27T14:41:15.1623937Z ==============================================================================
  2019-08-27T14:41:15.1624042Z Task         : Command Line
  2019-08-27T14:41:15.1624091Z Description  : Run a command line script using cmd.exe on Windows and bash on macOS and Linux.
  2019-08-27T14:41:15.1624157Z Version      : 2.146.1
  2019-08-27T14:41:15.1624203Z Author       : Microsoft Corporation
  2019-08-27T14:41:15.1624258Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613735)
  2019-08-27T14:41:15.1625058Z ==============================================================================
  2019-08-27T14:41:15.6151701Z Cannot invoke method. Method invocation is supported only on core types in this language mode.
  2019-08-27T14:41:15.6151921Z At line:1 char:1
  2019-08-27T14:41:15.6151968Z + . ([scriptblock]::Create('if (!$PSHOME) { $null = Get-Item -LiteralPa ...
  2019-08-27T14:41:15.6152019Z + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2019-08-27T14:41:15.6152077Z     + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
  2019-08-27T14:41:15.6152123Z     + FullyQualifiedErrorId : MethodInvocationNotSupportedInConstrainedLanguage
  2019-08-27T14:41:15.6152156Z  
  2019-08-27T14:41:17.7569608Z Cannot invoke method. Method invocation is supported only on core types in this language mode.
  2019-08-27T14:41:17.7569833Z At line:1 char:740
  2019-08-27T14:41:17.7570630Z + ... Continue' ; Invoke-VstsTaskScript -ScriptBlock ([scriptblock]::Create ...
  2019-08-27T14:41:17.7571090Z +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2019-08-27T14:41:17.7572452Z     + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
  2019-08-27T14:41:17.7574051Z     + FullyQualifiedErrorId : MethodInvocationNotSupportedInConstrainedLanguage
  2019-08-27T14:41:17.7574178Z  
  2019-08-27T14:41:17.8271008Z ##[error]Exit code 1 returned from process: file name 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe', arguments '-NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". ([scriptblock]::Create('if (!$PSHOME) { $null = Get-Item -LiteralPath ''variable:PSHOME'' } else { Import-Module -Name ([System.IO.Path]::Combine($PSHOME, ''Modules\Microsoft.PowerShell.Management\Microsoft.PowerShell.Management.psd1'')) ; Import-Module -Name ([System.IO.Path]::Combine($PSHOME, ''Modules\Microsoft.PowerShell.Utility\Microsoft.PowerShell.Utility.psd1'')) }')) 2&gt;&amp;1 | ForEach-Object { Write-Verbose $_.Exception.Message -Verbose } ; Import-Module -Name 'C:\TOOLS\agent\_work\_tasks\CmdLine_d9bafed4-0b18-4f58-968d-86655b4d2ce9\2.146.1\ps_modules\VstsTaskSdk\VstsTaskSdk.psd1' -ArgumentList @{ NonInteractive = $true } -ErrorAction Stop ; $VerbosePreference = 'SilentlyContinue' ; $DebugPreference = 'SilentlyContinue' ; Invoke-VstsTaskScript -ScriptBlock ([scriptblock]::Create('. ''C:\TOOLS\agent\_work\_tasks\CmdLine_d9bafed4-0b18-4f58-968d-86655b4d2ce9\2.146.1\cmdline.ps1'''))"'.
  2019-08-27T14:41:17.8301183Z ##[section]Finishing: Find python version
  </code></pre>
  
  <p>This command runs fine when I execute it from a commandline interactively in my machine.</p>
  
  <p>Why is the PowerShell getting invoked when the pipeline runs? And why such a long command to execute something so simple?</p>
  
  <p>Thanks in advance for any suggestions you can give.</p>