WebRequest using PowerShell

A pretty interesting way to make a WebRequest in Windows using WScript object, PowerShell, and reading the result from the clipboard:

REM  *****  BASIC  *****

Sub MakeWebRequest()

    Dim shell As Object
    Set shell = CreateObject("WScript.Shell")
    shell.Run "powershell -command ""Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.Clipboard]::Clear()""", 0, True
    shell.Run "powershell -Command ""Invoke-WebRequest http://www.lipsum.com/feed/xml | Set-Clipboard""", 0, True
    Set shell = Nothing
    Wait 500 'increase if needed
    MsgBox getClipboardText()
    
End Sub

Function getClipboardText() As String

    Dim oClip As Object
    Dim oConverter As Object
    Dim oClipContents As Object
    Dim aDataFlavours As Object
    Dim i%

    oClip = createUnoService("com.sun.star.datatransfer.clipboard.SystemClipboard")
    oConverter = createUnoService("com.sun.star.script.Converter")
    If IsNull(oClip.getContents) Or IsEmpty(oClip.getContents) Then
    	oClip = Nothing : getClipboardText = "" : Exit Function
    End If
    
    oClipContents = oClip.getContents
    aDataFlavours = oClipContents.getTransferDataFlavors

    For i = LBound(aDataFlavours) To UBound(aDataFlavours)
        If aDataFlavours(i).MimeType = "text/plain;charset=utf-16" Then
            Exit For
        End If
    Next

    If (i >= 0) Then
        On Error Resume Next
        getClipboardText = oConverter.convertToSimpleType _
            (oClipContents.getTransferData(aDataFlavours(i)), com.sun.star.uno.TypeClass.STRING)
         If Err <> 0 Then Err.Clear   
    End If
    
End Function