How do I test for previous execution for various one-time commands

10 views
Skip to first unread message

Joseph Flynn

unread,
Jan 4, 2018, 9:45:05 PM1/4/18
to ACMESharp
I'm trying to script a complete run which would include testing if various commands are already complete prior to running them again.

I can test for installation and importation of the code with

if (!(Get-Module "ACMESharp")) {
   
# module is not loaded
   
Install-Module -Name ACMESharp -AllowClobber -Scope CurrentUser
}

If (!(Get-module ACMESharp )) {
   
Import-Module ACMESharp
}

I can test for the presence of EFS with

$VaultOverride = ""
$x
= ""
$efsTestFile
= "$($env:ProgramData)\testing-efs.txt"
try
{
 
## If EFS isn't supported, it will fail with this call to Create
  $x
= [System.IO.File]::Create($efsTestFile, 100, "Encrypted")
  $x
.WriteByte(65)
  $x
.Close()
}
catch
{
   
"EFS not available."

    $VaultOverride
= "my-vault"
   
Set-ACMEVaultProfile -ProfileName my-vault -Provider local -VaultParameters @{ RootPath = "$env:LocalAppData\MyAcmeVault"; CreatePath = $true; BypassEFS = $true }
}
finally
{
 
del $efsTestFile
}

Totally a rookie newb here so please bear with me... 

How can I test for whether or not the following commands have already been run?

Initialize-ACMEVault -VaultProfile $VaultOverride
New-ACMERegistration -VaultProfile $VaultOverride -Contacts mailto:me@mine.com -AcceptTos

Thanks. 
Reply all
Reply to author
Forward
0 new messages