Dùng powershell để download file
- User
Dùng powershell để download file
- Assistant
Để tải xuống một tệp từ Internet bằng PowerShell, bạn có thể sử dụng lệnh
Invoke-WebRequesthoặcStart-BitsTransfer. Dưới đây là ví dụ cho cả hai cách:Cách 1: Dùng
Invoke-WebRequestpowershell$Uri = "https://example.com/path/to/your/file.txt" $Output = "C:\path\to\your\output\file.txt" Invoke-WebRequest -Uri $Uri -OutFile $OutputCách 2: Dùng
Start-BitsTransferpowershell$Uri = "https://example.com/path/to/your/file.txt" $Output = "C:\path\to\your\output\file.txt" Start-BitsTransfer -Source $Uri -Destination $OutputLưu ý:
- Thay thế
https://example.com/path/to/your/file.txtbằng URL thực tế của tệp mà bạn muốn tải xuống. - Thay thế
C:\path\to\your\output\file.txtbằng đường dẫn thực tế nơi bạn muốn lưu tệp tải xuống. - Đảm bảo rằng bạn có quyền ghi vào vị trí mà bạn chỉ định để lưu tệp.
- Thay thế
- Assistant
Có vẻ như bạn đã gửi một tin nhắn trống. Nếu bạn có câu hỏi hoặc yêu cầu nào đó, hãy cho tôi biết! Tôi sẵn sàng giúp đỡ bạn.
- User
Output lưu ở folder hiện tại
- Assistant
Nếu bạn muốn lưu tệp tải xuống vào thư mục hiện tại (thư mục mà bạn đang làm việc trong PowerShell), bạn có thể sử dụng dấu chấm (.) để biểu thị thư mục hiện tại. Dưới đây là cách sử dụng cả hai phương pháp
Invoke-WebRequestvàStart-BitsTransferđể lưu tệp vào thư mục hiện tại:Cách 1: Dùng
Invoke-WebRequestpowershell$Uri = "https://example.com/path/to/your/file.txt" $Output = ".\file.txt" # Lưu tệp ở thư mục hiện tại Invoke-WebRequest -Uri $Uri -OutFile $OutputCách 2: Dùng
Start-BitsTransferpowershell$Uri = "https://example.com/path/to/your/file.txt" $Output = ".\file.txt" # Lưu tệp ở thư mục hiện tại Start-BitsTransfer -Source $Uri -Destination $OutputLưu ý:
- Thay thế
https://example.com/path/to/your/file.txtbằng URL thực tế của tệp mà bạn muốn tải xuống.
- Thay thế