回答編集履歴
1
サンプルコードが間違っていたので修正
test
CHANGED
@@ -14,19 +14,39 @@
|
|
14
14
|
|
15
15
|
```powershell
|
16
16
|
|
17
|
-
$pso = New-Object -TypeName psobject -
|
17
|
+
[psobject]$pso = New-Object -TypeName psobject -Property @{A=1;B=2}
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
Write-Output -InputObject $pso
|
18
22
|
|
19
23
|
|
20
24
|
|
21
25
|
[string]$nameOfProperty = 'a'
|
22
26
|
|
23
|
-
$pso.$nameOfProperty # => 1
|
27
|
+
'{0} = {1}' -f $nameOfProperty , $pso.$nameOfProperty # => 1
|
24
28
|
|
25
29
|
|
26
30
|
|
27
31
|
$nameOfProperty = 'B'
|
28
32
|
|
29
|
-
$pso.$nameOfProperty # => 2
|
33
|
+
'{0} = {1}' -f $nameOfProperty , $pso.$nameOfProperty # => 2
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
<# 結果
|
38
|
+
|
39
|
+
A B
|
40
|
+
|
41
|
+
- -
|
42
|
+
|
43
|
+
1 2
|
44
|
+
|
45
|
+
a = 1
|
46
|
+
|
47
|
+
B = 2
|
48
|
+
|
49
|
+
#>
|
30
50
|
|
31
51
|
```
|
32
52
|
|