# Upgrade powershell code to ACMEv2 protocol

**URL:** <https://community.letsencrypt.org/t/upgrade-powershell-code-to-acmev2-protocol/114100>\
**Category:** Help\
**Created:** [February 24, 2020, 11:48am UTC](https://community.letsencrypt.org/t/upgrade-powershell-code-to-acmev2-protocol/114100 "2020-02-24T11:48:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![haviay](https://avatars.discourse-cdn.com/v4/letter/h/e9bcb4/32.png) [@haviay](https://community.letsencrypt.org/u/haviay)\
**Post date:** [February 24, 2020, 11:48am UTC](https://community.letsencrypt.org/t/upgrade-powershell-code-to-acmev2-protocol/114100/1 "2020-02-24T11:48:18Z")

</div>

Hi,  
i use ACMESharp via power shell to create multiple domains per certificates  
How can i rewrite this code below?

```
#install-Module -Name ACMESharp

import-module ACMESharp

$email = "mailto:admin@admin.com"
$iissitename = "websitename"
$certname = "aaa15$(get-date -format yyyy-MM-dd--HH-mm)"
$pfxfile = "C:\Certs\03\pfx\$certname.pfx"

$initializevault = $FALSE
$createregistration = $FALSE
$createalias = $TRUE

$domains = @(<...list of domains...>			
	)

$aliases = @()

# Change to the Vault folder
cd C:\ProgramData\ACMESharp\sysVault

# First time on the machine - intiialize vault
if($initializevault) 
{
    Initialize-ACMEVault
}

Get-ACMEVault

if($createregistration) 
{
    # Set up new 'account' tied to an email address
     New-AcmeRegistration -Contacts "$email" -AcceptTos
}
For ($i=0; $i -lt $domains.Length; $i++) {
	 
		$aliases += @($domains[$i]+$(get-date -format yyyyMMddHHmm))
		# Associate a new site 
		New-AcmeIdentifier -Dns $domains[$i] -Alias $aliases[$i]
		#New-ACMEIdentifier -Dns $domain2 -Alias $alias2

		# Prove the site exists and is accessible => (This creates files at .well-known\acme-challenge folder)
		Complete-ACMEChallenge $aliases[$i] -ChallengeType http-01 -Handler iis -HandlerParameters @{WebSiteRef="$iissitename"} -Force
		#Complete-ACMEChallenge $alias2 -ChallengeType http-01 -Handler iis -HandlerParameters @{WebSiteRef="$iissitename"} -Force

		# Validate site
		Submit-ACMEChallenge $aliases[$i] -ChallengeType http-01 -Force
		#Submit-ACMEChallenge $alias2 -ChallengeType http-01 -Force

		# check until valid or invalid - pending =>(Just check the status field)
		Update-ACMEIdentifier $aliases[$i] -ChallengeType http-01
		#Update-ACMEIdentifier $alias2 -ChallengeType http-01 
	
}
```

---

<div class="post-metadata">

**Author:** ![stevenzhu](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/stevenzhu/32/18864_2.png) [@stevenzhu](https://community.letsencrypt.org/u/stevenzhu)\
**Post date:** [February 24, 2020, 5:03pm UTC](https://community.letsencrypt.org/t/upgrade-powershell-code-to-acmev2-protocol/114100/2 "2020-02-24T17:03:40Z")

</div>

Hi,

You can open an issue with ACMESharp’s repo in the link below as they are more familiar with their code.

> **[ebekker/ACMESharp](https://github.com/ebekker/ACMESharp/issues)**
>
> An ACME client library and PowerShell client for the .NET platform (Let's Encrypt) - ebekker/ACMESharp

Thank you

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/letsencrypt/original/3X/c/a/ca6c06ea1ea201324bba7048c6841ce60236468d.png) [@system](https://community.letsencrypt.org/u/system)\
**Post date:** [March 25, 2020, 5:03pm UTC](https://community.letsencrypt.org/t/upgrade-powershell-code-to-acmev2-protocol/114100/3 "2020-03-25T17:03:40Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
