$ErrorActionPreference = 'continue'
[System.net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
$console_server = 'puppetmater.domain'
$node = "node.domain"
$action = @{desired_state='revoked'}
$json = $action | ConvertTo-Json
$url = "https://${console_server}:8140/puppet-ca/v1/certificate_status/${node}"
echo $url
$results = Invoke-RestMethod -Uri "$url" -body $json -method PUT -Certificate (Get-PfxCertificate -FilePath \\server\puppet-certs\Non-Production\certname)
$url = "https://${console_server}:8140/puppet-ca/v1/certificate_status/${node}"
$response = Invoke-RestMethod -Uri "$url" -method DELETE -Certificate (Get-PfxCertificate -FilePath \\server\puppet-certs\Non-Production\certname)
echo $response
$deactivateAction = @{command="deactivate node"
version='3'
payload=@{
certname="$node"
}
}
$json2 = $deactivateAction | ConvertTo-Json
$commandURL = "https://${console_server}:8081/pdb/cmd/v1"
echo $json2
$response = Invoke-RestMethod -Uri $commandURL -Method Post -ContentType 'application/json' -Body $json2 -Certificate (Get-PfxCertificate -FilePath \\server\puppet-certs\Non-Production\certname.pfx)
echo $response