1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Invoke-WebRequestはiwrで実行できるしcdの実態はSet-Location

Posted at

PowerShellはコマンドプロンプトに比べてちょっとだけLinuxっぽいシェルになってる。

その実態はエイリアスをLinuxっぽくしてるだけで、実態はゴリゴリのPowerShellのメソッド。

PS C:\Users\yugoy> alias

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Alias           ? -> Where-Object
Alias           % -> ForEach-Object
Alias           ac -> Add-Content
Alias           cat -> Get-Content
Alias           cd -> Set-Location
Alias           chdir -> Set-Location
Alias           clc -> Clear-Content
Alias           clear -> Clear-Host
Alias           clhy -> Clear-History
..

PowerShellのコマンドなげーよ!と思った人は、エイリアスをみれば短いコマンドがあるかも知れない。

例えば、Invoke-WebRequestが長いけどiwrというエイリアスがある。こんな感じでレスポンスを取り出すことができる。

PS C:\Users\yugoy> (iwr http://yahoo.co.jp).content

PowerShellのメソッドは標準出力に値を返すのではなくオブジェクトを返すので、テキストだけ取り出したいときにはさらにメソッドを呼び出す必要がある。一見面倒くさいけど、レスポンスのヘッダとボディを分けて扱いたいときにはちょうど便利。

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?