Skip to content

Instantly share code, notes, and snippets.

@thefamousbrian
Last active February 19, 2021 14:40
Show Gist options
  • Save thefamousbrian/16aea19b9e2eef6dea55a7db073959ad to your computer and use it in GitHub Desktop.
Save thefamousbrian/16aea19b9e2eef6dea55a7db073959ad to your computer and use it in GitHub Desktop.
certutil error checking Powershell DSC Script resource
# Install local cert with certutil
Script localcert {
SetScript = {
$certPath = "C:\Installers\$using:cert"
$result = $(certutil -p $using:cert_pass -csp "Microsoft Enhanced RSA and AES Cryptographic Provider" -importpfx $certPath)
if($result -like '*FAILED*') {
Throw "certutil failed for local cert $certPath $result"
}
}
TestScript = { $false }
GetScript = { }
}
# Install claims cert with certutil
Script claimscert {
SetScript = {
$certPath = "C:\Installers\$using:claims_cert"
$result = $(certutil -p $using:claims_cert_pass -csp "Microsoft Enhanced RSA and AES Cryptographic Provider" -importpfx $certPath)
if($result -like '*FAILED*') {
Throw "certutil failed for claims cert $certPath $result"
}
}
TestScript = { $false }
GetScript = { }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment