---
# System prepended metadata

title: Test für invoke-webrequest

---

# Test für invoke-webrequest
```
function get-BApfx 
{
    param(
    [Parameter(Mandatory = $true)]
    [String]$URL, 
    [Parameter(Mandatory = $true)]
    [String]$Path)
       
        #username
        $credentials =  Get-Credential -Message 'Bitte geben Sie Ihre p-Kennung und Ihr Kennwort ein.'

        $Webrequest = Invoke-WebRequest -Uri $URL -Credential ($credentials)
        #checks for Web-Server status 
        if ($?)
        {
            $i = ($Webrequest).links.href
            if ($i.Count -eq 2)
            {
                #Filepath
                $pfxFilePath = ($Webrequest).links.href[1]
                    
                #Create File
                Invoke-WebRequest -Uri $URL$pfxFilePath -Credential ($credentials) -OutFile $path
                Write-Host "fertig"
                }
                }
                else{ Write-Host "Es ist ein Problem da."
                }
                }
               
    write-host $URL
    write-host $Path
    
    write-host $URL + $Path
    
get-BApfx -URL  https://pankow-mobil.verwalt-berlin.de/certs/      -Path C:\Users\$env:USERNAME\Downloads\licence.pfx
```