diff --git a/Renew-WAPApplications.ps1 b/Renew-WAPApplications.ps1 new file mode 100644 index 0000000..dcdc9ca --- /dev/null +++ b/Renew-WAPApplications.ps1 @@ -0,0 +1,19 @@ +# Created by Peter Wickenberg +# Date 2022-08-01 +# Version 1.0 + +# Store {CertCommonName} as fqdn variable +$fqdn = $args[0] +write-host CertCommonName is $fqdn +# Get WAP Application and store as variable +$app = Get-WebApplicationProxyApplication | Where-Object {$_.ExternalUrl -Match "https://" + "$fqdn"} +write-host WAP Application is $app.Name and it has ID $app.ID + +# Set Let's encrypt certificate for WAP Application +write-host Changing to the latest certificate +Set-WebApplicationProxyApplication ` + -ID $app.ID ` + -BackendServerUrl "$($app.backendserverurl)"` + -ExternalCertificateThumbprint $((get-childitem Cert:\LocalMachine\My\ | `select subject,thumbprint,@{ Label = 'IssuedBy' ;Expression = { $_.GetNameInfo( 'SimpleName', $true ) } } | ? {($_.IssuedBy -like "R3*") -and ($_.Subject -like "CN=$fqdn")} | select -First 1).Thumbprint)` + -ExternalUrl "$($app.externalURL)"` + -Name "$($app.name.substring(0,1).toupper()+$app.name.substring(1).tolower())" \ No newline at end of file