# pfx-installation.ps1 (OLD)
```
#savepath
#$path = "C:\Users\$env:USERNAME\Downloads\licence.pfx"
#URL/URI
#$URL = 'https://pankow-mobil.verwalt-berlin.de/certs/'
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
}
else
{
#error message for user
$wshell = New-Object -ComObject Wscript.Shell
$Output = $wshell.Popup("Es ist ein Fehler enstanden. Bitte melden Sie sich im Bereich ITK für weitere Hilfe. Tel: -6666
Fehlercode: Mehrere Zertifikate ",0,"Error",0+16)
}
}
else
{
#error message: wrong "p-Kennung" or "password"
$wshell = New-Object -ComObject Wscript.Shell
$Output = $wshell.Popup("Benutzername oder Kennwort falsch. Bitte versuchen Sie es erneut",0,"Login Fehler",5+48)
}
}
function install-BApfx
{
param(
[Parameter(Mandatory = $true)]
[String]$path)
#certificate-PIN
$PIN = Get-Credential -UserName 'Bitte PIN unten eingeben.' -Message 'Bitte geben Sie Ihre PIN aus dem Anschreiben vom ITDZ mit der Überschrift "Zertifikatausstellung" unten im Feld Kennwort ein.'
Import-PfxCertificate -FilePath $path -CertStoreLocation Cert:\CurrentUser\My -Password $PIN.Password
if ($?)
{
$wshell = New-Object -ComObject Wscript.Shell
$wshell.Popup("Zertifikat installiert",0,"Erfolg!",0x1)
}
else
{
#error message for user
$wshell = New-Object -ComObject Wscript.Shell
$Output = $wshell.Popup("PIN wurde falsch eingegeben. Bitte versuchen Sie es erneut",0,"Error",5+48)
}
}
function Remove-BApfx
{
param(
[Parameter(Mandatory = $true)]
[String]$path)
#remove
Remove-Item -LiteralPath $path
}
#run functions in order
get-BApfx
install-BApfx
Remove-BApfx
```