Yanor.net/
Wiki
Blog
GitHub
Sandbox
開始行:
* パイプライン入力 2 - ByPropertyName [#c9b2d75a]
** 概要 [#h7cbafb9]
CommandletA | CommandletB
- PowerShellでパイプで値を渡す方法は2つある。ByValue と B...
- ByValueがデフォルトで、PowerShellはパイプからByValueな...
- ここではByPropertyNameについて説明する。
** 例 [#y50b813f]
PS> dir A
Mode LastWriteTime FileSize Name
---- ------------- -------- ----
-a---- 2018/07/10 9:08 0 B 1.txt
-a---- 2018/07/10 9:08 0 B 2.txt
-a---- 2018/07/10 9:08 0 B 3.txt
- Aというディレクトリに1.txtや2.txtなどがある。
- これらのtxtファイルと同じファイル名のファイルをカレント...
** dir Aがどんな値を出力するかGet-Memberで調べる [#r0eeaa...
PS> dir A | gm
TypeName: System.IO.FileInfo
- 型がFileInfoなのがわかる。
*** New-Itemがどんなパイプライン入力を受け取るかHelpで調...
PS> help New-Item -Full
構文
New-Item [[-Path] <String[]>] [-Confirm] [-Credential...
-Name <String> [-UseTransaction] [-Value <Ob...
-Name <String>
Specifies the name of the new item.
You can specify the name of the new item in the Name...
必須 true
位置 named
既定値 None
パイプライン入力を許可する True (ByPropertyName)
ワイルドカード文字を許可する false
- Nameというプロパティ(型はString)をByPropertyNameで受...
*** dirが出力する値がどんなプロパティを持っているか、help...
PS> help dir -Full
LastWriteTimeUtc Property datetime LastWr...
Length Property long Length {ge...
Name Property string Name {ge...
- dirが出力する値、つまりFileInfo型にNameプロパティが存在...
PS> dir A\*.txt | New-Item
PS> dir
Mode LastWriteTime FileSize Name
---- ------------- -------- ----
d----- 2018/07/10 9:08 A
-a---- 2018/07/10 9:14 0 B 1.txt
-a---- 2018/07/10 9:14 0 B 2.txt
-a---- 2018/07/10 9:14 0 B 3.txt
- したがって、このパイプ処理は正常に終了する。
** 参考 [#n0b806c2]
https://blogs.technet.microsoft.com/heyscriptingguy/2013/...
終了行:
* パイプライン入力 2 - ByPropertyName [#c9b2d75a]
** 概要 [#h7cbafb9]
CommandletA | CommandletB
- PowerShellでパイプで値を渡す方法は2つある。ByValue と B...
- ByValueがデフォルトで、PowerShellはパイプからByValueな...
- ここではByPropertyNameについて説明する。
** 例 [#y50b813f]
PS> dir A
Mode LastWriteTime FileSize Name
---- ------------- -------- ----
-a---- 2018/07/10 9:08 0 B 1.txt
-a---- 2018/07/10 9:08 0 B 2.txt
-a---- 2018/07/10 9:08 0 B 3.txt
- Aというディレクトリに1.txtや2.txtなどがある。
- これらのtxtファイルと同じファイル名のファイルをカレント...
** dir Aがどんな値を出力するかGet-Memberで調べる [#r0eeaa...
PS> dir A | gm
TypeName: System.IO.FileInfo
- 型がFileInfoなのがわかる。
*** New-Itemがどんなパイプライン入力を受け取るかHelpで調...
PS> help New-Item -Full
構文
New-Item [[-Path] <String[]>] [-Confirm] [-Credential...
-Name <String> [-UseTransaction] [-Value <Ob...
-Name <String>
Specifies the name of the new item.
You can specify the name of the new item in the Name...
必須 true
位置 named
既定値 None
パイプライン入力を許可する True (ByPropertyName)
ワイルドカード文字を許可する false
- Nameというプロパティ(型はString)をByPropertyNameで受...
*** dirが出力する値がどんなプロパティを持っているか、help...
PS> help dir -Full
LastWriteTimeUtc Property datetime LastWr...
Length Property long Length {ge...
Name Property string Name {ge...
- dirが出力する値、つまりFileInfo型にNameプロパティが存在...
PS> dir A\*.txt | New-Item
PS> dir
Mode LastWriteTime FileSize Name
---- ------------- -------- ----
d----- 2018/07/10 9:08 A
-a---- 2018/07/10 9:14 0 B 1.txt
-a---- 2018/07/10 9:14 0 B 2.txt
-a---- 2018/07/10 9:14 0 B 3.txt
- したがって、このパイプ処理は正常に終了する。
** 参考 [#n0b806c2]
https://blogs.technet.microsoft.com/heyscriptingguy/2013/...
ページ名: