LoginSignup
3
7

More than 5 years have passed since last update.

Power Shell でファイルをダウンロードする

Last updated at Posted at 2017-09-02

やりたいこと

  • あるサイトに置いてあるzipファイルを、自分のPCにダウンロードする。
  • ファイルがいっぱいあるので右クリックで保存したくない。
  • やましいファイルではなく、日別の集計データです。

注意すること

  • 基本的にブラウザからアクセスされる前提なので、プログラムで全力アクセスすると怒られる。
  • 節度を持ったアクセスが必要。

利用ツール

Windows Power Shell

サンプル

# WebClient 生成
$cli = New-Object System.Net.WebClient

# 対象URL
$uri = New-Object System.Uri("http://hoge/fuga.zip")

# 保存時のファイル名を取得
$file = Split-Path $uri.AbsolutePath -Leaf

# ダウンロード
$cli.DownloadFile($uri, (Join-Path "C:\Users\xxxx\" $file))

ループとか外部ファイルからURL指定とかは、また別途...

3
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
7