I want to download a file with powershell and here is a part of script
$downloadurl ="https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community&channel=Release&version=VS2022&source=VSLandingPage&cid=2030&passive=false" Start-BitsTransfer -Source "$downloadurl" -Destination "$thisLocalFile"
and a destination is defined but I get this error
The file size was not returned by the server. The URL may contain dynamic content. The content length header is not available in the server HTTP response available.
then I used (New-Object System.Net.WebClient).DownloadFile($downloadurl, $thisLocalFile)
it will be downloaded but not complete because the size of the file is less than what it should be .can somebody help me to solve the problem, thanks in advance.