invoke-webrequest download file

To download a file using the Invoke-WebRequest command in C#, you can use the following code:

using System.Net;

string url = "https://example.com/file.txt";
string savePath = "C:\\path\\to\\save\\file.txt";

using (WebClient client = new WebClient())
{
    client.DownloadFile(url, savePath);
}

Replace "https://example.com/file.txt" with the actual URL of the file you want to download, and "C:\\path\\to\\save\\file.txt" with the desired path and filename to save the downloaded file.

This code uses the WebClient class from the System.Net namespace to download the file. The DownloadFile method is used to download the file from the specified URL and save it to the specified path.

Please note that you need to include the System.Net namespace at the top of your C# file for this code to work.

[1]