I am invoking a library in Powershell that using the .NET HttpClient to make a POST request. The client call runs on a background thread. It works fine for HTTP. When I use HTTPS however I run into issues. The server is not using a valid signed cert. I disabled that check properly using:
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
only to be met by this error related to runspaces:
System.Management.Automation.PSInvalidOperationException: There is no Runspace available to run scripts in this thread. You can provide one in the DefaultRunspace property of the System.Management.Automation.Runspaces.Runspace type. The script block you attempted to invoke was: $true
From a bit of research it appears to be related to the fact that the API is async / using tasks.
Any help would be greatly appreciated.