12:23 pm • 10 Comments

# How to download files with Powershell

This should show you how you can download a file with Powershell. This is not a script or function you should use. It just is the the easyiest way to download a file with Powershell. If I have enough time I will create a function for downloading files.

```\$Url = "https://www.thomasmaurer.ch/ps.txt"
\$Path = "C:\temp\ps.txt"
\$Username = ""
\$Password = ""

\$WebClient = New-Object System.Net.WebClient
\$WebClient.Credentials = New-Object System.Net.Networkcredential(\$Username, \$Password)
\$WebClient.DownloadFile( \$url, \$path )```

Tags: , , , , , , , , , , , , , Last modified: January 7, 2019
Close