プロジェクト

全般

プロフィール

PowerShell関係のメモ » 履歴 » バージョン 1

sylow castle, 2020/01/13 19:52

1 1 sylow castle
# PowerShell関係のメモ
2
3
## 概要
4
5
色々メモしておく。大きなったなったら独立する。
6
7
## メモ
8
9
### PSスクリプト中でスクリプトのパスを取得
10
11
自分の位置を知りたくなったときなどに使う
12
13
```
14
$MyInvocation.MyCommand.Source
15
```
16
17
各変数の型も調べておこう。
18
19
```
20
Write-Output $MyInvocation.GetType()
21
Write-Output $MyInvocation.MyCommand.GetType()
22
Write-Output $MyInvocation.MyCommand.Source.GetType()
23
```
24
25
実行結果:
26
27
```
28
IsPublic IsSerial Name                                     BaseType
29
-------- -------- ----                                     --------
30
True     False    InvocationInfo                           System.Object
31
True     False    ExternalScriptInfo                       System.Management.Automation.CommandInfo
32
True     True     String                                   System.Object
33
```
34
35
$MyInvocation.MyCommand.SourceはString型らしい