aks131
07-09-2024, 04:34 PM
Need help converting this powersheel in VBA code. I am new to VBA , please advise/guide.
#Step 1: Authenticate securily to API Server
$certStore = "CurrentUser"; # Alternative: LocalMachine
$subFieldName = "CN";
$issuedTo = "PS Cloud Authentication, O=APISafe, OU=Development, C=Canada";
#Step 2: "Finding client certificate..";
$certs = Get-ChildItem -Path "cert:\${certStore}\My" -EKU "Client Authentication";
$cert = $certs | Where-Object { $_.Subject -eq "${subFieldName}=${issuedTo}" };
#Write-Output $cert
$cert;
[System.Security.Cryptography.X509Certificates.X509Certificate2]$script:authCert = $cert
Psafe-SignAppIn
#Secure Connection
$baseUrl = https://APISafe/api/public/v3/;
#The Application API Key generated in APISafeInsight
$apiKey = "This is where the API key will be once it is given to you.";
#Username of APISafeInsight user granted permission to the API Key
$runAsUser = "TESTAPI";
$clientCertificateType = "BICertificate";
#Step 1: Authenticate securily to API Server
$certStore = "CurrentUser"; # Alternative: LocalMachine
$subFieldName = "CN";
$issuedTo = "PS Cloud Authentication, O=APISafe, OU=Development, C=Canada";
#Step 2: "Finding client certificate..";
$certs = Get-ChildItem -Path "cert:\${certStore}\My" -EKU "Client Authentication";
$cert = $certs | Where-Object { $_.Subject -eq "${subFieldName}=${issuedTo}" };
#Write-Output $cert
$cert;
[System.Security.Cryptography.X509Certificates.X509Certificate2]$script:authCert = $cert
Psafe-SignAppIn
#Secure Connection
$baseUrl = https://APISafe/api/public/v3/;
#The Application API Key generated in APISafeInsight
$apiKey = "This is where the API key will be once it is given to you.";
#Username of APISafeInsight user granted permission to the API Key
$runAsUser = "TESTAPI";
$clientCertificateType = "BICertificate";