Согласно справке:
> get-help Invoke-RestMethod -Parameter Timeoutsec
-TimeoutSec <Int32>
Specifies how long the request can be pending before it times out. Enter a value in seconds. The default value, 0, specifies an indefinite time-out.
Поэтому параметру необходимо целое число, чтобы указать, сколько времени должно быть до тайм-аута.
Invoke-RestMethod $uri -TimeoutSec 4
Обратите внимание на предостережение, которое также находится впомощь:
A Domain Name System (DNS) query can take up to 15 seconds to return or time out. If your request contains a host name that requires resolution, and you set TimeoutSec to a value greater than zero, but less than 15 seconds, it can take 15
seconds or more before a WebException is thrown, and your request times out.