The line [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12, [Net.SecurityProtocolType]::Tls13 throws an error on systems that do not support TLS 1.3.
I suggest checking first to see if the system supports TLS 1.3 and, if not, only invoking: [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12