powershell enable tls 1.2

try {
    # Check if TLS 1.2 is available, if not add it.
    if (\[Net.ServicePointManager\]::SecurityProtocol -notcontains 'Tls12') {
        \[Net.ServicePointManager\]::SecurityProtocol += \[Net.SecurityProtocolType\]::Tls12
    }
}
catch {
    throw "Can not enable Tls12"
}

you may need this for cases where you receive errors complaining that it is not possible to create tls connection