PowerShell usage
Introduction
Akeyless Vault Platform natively supports multiple scripting languages, the following examples demonstrate how to fetch secrets from Akeyless Vault via PowerShell script:
Usage
The following example demonstrate fetching dynamic secret:
$AuthBody = @{
"access-id" = "******"
"access-key" = "************"
"access-type" = "access_key"
}
$AuthParameters = @{
Method = "POST"
Uri = "https://api.akeyless.io/auth"
Body = ($AuthBody | ConvertTo-Json)
ContentType = "application/json"
}
$token = (Invoke-RestMethod @AuthParameters).token
Write-Host "NEW TOKEN: [$token]"
$SecretBody = @{
"name" = "/full/path/mySecret"
"token" = "$token"
}
$SecretParameters = @{
Method = "POST"
Uri = "https://api.akeyless.io/get-dynamic-secret-value"
Body = ($SecretBody | ConvertTo-Json)
ContentType = "application/json"
}
Invoke-RestMethod @SecretParameters
The following example demonstrate fetching static secret:
$AuthBody = @{
"access-id" = "******"
"access-key" = "************"
"access-type" = "access_key"
}
$AuthParameters = @{
Method = "POST"
Uri = "https://api.akeyless.io/auth"
Body = ($AuthBody | ConvertTo-Json)
ContentType = "application/json"
}
$token = (Invoke-RestMethod @AuthParameters).token
Write-Host "NEW TOKEN: [$token]"
$SecretBody = @{
"names" = @("mySecret")
"token" = "$token"
}
$SecretParameters = @{
Method = "POST"
Uri = "https://api.akeyless.io/get-secret-value"
Body = ($SecretBody | ConvertTo-Json)
ContentType = "application/json"
}
Invoke-RestMethod @SecretParameters
Updated 12 days ago