I have found plenty of resource on the first part of my question, specifically though I'm looking for solutions for it being used with task scheduler / service account
I have a PowerShell script which sucks up some logs and forwards them to an endpoint. This is run via a scheduled task. The account that does the forwarding has a valid certificate to be able to send to the end point
I have tested the PowerShell script using my certificate and it works as intended. I have also tested that the service accounts certificate is valid but from being run as myself as opposed to the service account. I am unable to test it from the service account as it does not have any logon rights
I have updated the [net.servicepointmanager]::securityprotocol
as stated here.
I believe the error Could not create ssl/tls secure channel
is the correct error but I believe the cause is not the common one found by googling this
What else should I test to see what's going on here? PSVersion 5.1, .Net 4.5
As requested here a bunch of the code I am using to gain the certificate of the service account
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$subject = "account"
$certs = Get-ChildItem("certs:\") -recurce | Where-object {($_.Subject -like "*$subject*" -and $_.HasPrivateKey -eq $true)}
$cert = $certs | Sort-object $_."Not Before" | select-object -first 1
$file = gci(D:\Temp)
$contentType = "application/json"
$request = Invoke-Webrequest -uri "mydestination" -Certificate $cert -Method Post -infile $file.Fullname -contentType $contentType