Download the file at url to target using Powershell (which will validate
    trust). Raise an exception if the command cannot complete.

def download_file_powershell(url, target, headers={}):
    """
    Download the file at url to target using Powershell (which will validate
    trust). Raise an exception if the command cannot complete.
    """
    target = os.path.abspath(target)

    powershell_cmd = "$request = (new-object System.Net.WebClient);"
    for k, v in headers.items():
        powershell_cmd += "$request.headers['%s'] = '%s';" % (k, v)
    powershell_cmd += "$request.DownloadFile(%(url)r, %(target)r)" % vars()

    cmd = [
        'powershell',
        '-Command',
        powershell_cmd,
    ]

    _clean_check(cmd, target)