Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The Win32 internal error "The handle is invalid" 0x6 occurred while getting the console mode

I currently have some problems with the azure commandline in a Web App. I get following error:

[10/28/2015 20:22:33 > 37539e: ERR ] New-Item : The Win32 internal error "The handle is invalid" 0x6 occurred while 
[10/28/2015 20:22:33 > 37539e: ERR ] getting the console mode. Contact Microsoft Customer Support Services.

This occurred on New-Item and Remove-Item. It happens in the Kudo Powershell console and using Powershell-Scripts ina WebJob.

Instead of New-Item file I have successfully used echo 3 >> file. This worked without problems. The only thing I found was that there is a problem using Invoke-WebRequst and that it will be fixed using

$ProgressPreference="SilentlyContinue"

Unfortunately this didn't helped.

Did someone experienced something similar?

Thanks in advance.

like image 558
lokimidgard Avatar asked Oct 28 '15 20:10

lokimidgard


2 Answers

For me, setting $ProgressPreference="SilentlyContinue" does solve the issue. (Using the PowerShell Console of the Kudu site of an Azure App Service.)

$null | (…) > $null also prevents the error, but that also suppresses the return value, which I don't want.

Background: Apparently Invoke-WebRequest tries to display a progress bar, which Kudu's PowerShell does not support. (source)

like image 185
Grilse Avatar answered Nov 15 '22 15:11

Grilse


Some cmdlets may attempt to read the console mode of the standard input or standard output streams if it is attached to the console. This can be avoided by setting them explicitly to null.

# Prevent the progress meter from trying to access the console mode
$ProgressPreference = "SilentlyContinue"

# Set the input and output streams to $null
$null | Invoke-WebRequest -UseBasicParsing http://www.example.com/ > $null
like image 29
Ben Avatar answered Nov 15 '22 17:11

Ben