Windows: Get and decrypt password from rdp files

Hi,

rdp files can store the password for a connection. The password is protected with the users key who saved the file.
Continue reading Windows: Get and decrypt password from rdp files

openssl: Establish a http connect behind a proxy

Hi,

since openssl 1.1.0 it is possible to establish a HTTPs CONNECT connection to a (Web)server behind a http proxy.

Continue reading openssl: Establish a http connect behind a proxy

VMware Workstation: Using the REST api with powershell

Hi,

the most did not know that VMware Workstation has a API interface to dealing with it.
Continue reading VMware Workstation: Using the REST api with powershell

Powershell: Get the certificate of a webserver

Hi,

like openssl s_client you can also use powershell to view/get the certificate of a webserver.
Continue reading Powershell: Get the certificate of a webserver

Powershell: Invoke-WebRequest aborts with httpcode 301/308 permanent redirect

Hi,

the powershell command-let Invoke-WebRequest does not follow an http redirect.

The solution is to call Invoke-WebRequest recursivly with the redirect URL from the location header field when http code 301 or 308 is returned.

$sURL = "https://visualstudio.com/"
$sRedirectTo=$null
do {
    $oWebResponse = $null
    try
    {
        $oWebResponse = Invoke-WebRequest $sURL 
    }
    catch 
    {
        $oWebResponse=$_.Exception.Response
        write-host ("Exception: {0}" -f $_.Exception.Message)
    }
	if($oWebResponse.StatusCode -ne 200)
	{
		$aRedirectTo=$oWebResponse.Headers.GetValues("location")
		if($aRedirectTo.Count -ge 1)
		{
			$sRedirectTo=$aRedirectTo[0]
		}
		else
		{
			write-host ("No location URL in header")
			break
		}
		if (-not [string]::IsNullOrEmpty($sRedirectTo))
		{
			write-host ("Redirect to {0}" -f ($sRedirectTo))
			$sURL = $sRedirectTo
		}
		else
		{
			write-host ("location URL Null")
			break
		}
	}
    else
    {
        Write-Output ("OK Location = {1} HttpCode = {0}" -f $oWebResponse.StatusCode,$sRedirectTo )
        break
    }
	
} 
while ($true)

Michael

My Knowledgebase for things about Linux, Windows, VMware, Electronic and so on…