Hello @Robby Osting,
Here are my funtions for Logging in and Logging out, that I like to use in my powershell scripts:
$cookie = New-Object Microsoft.PowerShell.Commands.WebRequestSession
function Login{
  Invoke-WebRequest `
  "$($dwurl)/Account/Logon" `
  -Method Post `
  -Headers @{ `
      'Content-Type' = 'application/x-www-form-urlencoded'; `
      'Accept' = 'application/json'; } `
  -Body @{ `
      'UserName' = $($username); `
      'Password' = $($password); `
      'Organization' = $($org_name); `
      'RedirectToMyselfInCaseOfError' = 'false'; `
      'RememberMe' = 'false'; `
      'HostID' = '7b5ed19b-bfd6-46e9-8a3b-efd2a4499666'; `
      'LicenseType' = 'PlatformService'; } `
  -WebSession $cookie
}
function Logout{
  Invoke-WebRequest "$($dwurl)/Account/Logoff" `
  -Method Get `
  -WebSession $cookie
}
They use a few variables for the url, username, password, etc.
Please note the variable "$cookie". 
In between logging in and logging out, I send this with every Invoke-WebRequest that I make to do the actual work I want to do.
What does the html response aou are receiving contain?
I suspect there is an issue with licensing?