Guest User

Untitled

a guest
Nov 8th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.81 KB | None | 0 0
  1. $ConfigurationData = @{
  2. AllNodes = @(
  3. @{
  4. NodeName="*"
  5. PSDscAllowPlainTextPassword=$True
  6. PsDscAllowDomainUser=$True
  7. }
  8. )
  9. }
  10.  
  11. $ConfigurationData = @{
  12. AllNodes = @(
  13. @{
  14. NodeName="*"
  15. PSDscAllowPlainTextPassword=$True
  16. PsDscAllowDomainUser=$True
  17. NewItem = "SomeNewValue"
  18. AnotherNewItem = "Hello"
  19. }
  20. )
  21. }
  22.  
  23. $ConfigurationData.AllNodes += @{NewItem = "SomeNewValue"}
  24. $ConfigurationData.AllNodes += @{AnotherNewItem = "Hello"}
  25.  
  26. $ConfigurationData.AllNodes
  27.  
  28. Name Value
  29. ---- -----
  30. NodeName *
  31. PSDscAllowPlainTextPassword True
  32. PsDscAllowDomainUser True
  33. NewItem SomeNewValue
  34. AnotherNewItem Hello
  35.  
  36. $ConfigurationData | ConvertTo-Json
  37. {
  38. "AllNodes": [
  39. {
  40. "NodeName": "*",
  41. "PSDscAllowPlainTextPassword": true,
  42. "PsDscAllowDomainUser": true
  43. },
  44. {
  45. "NewItem": "SomeNewValue"
  46. },
  47. {
  48. "AnotherNewItem": "Hello"
  49. }
  50. ]
  51. }
  52.  
  53. $ConfigurationData = @{
  54. AllNodes = @(
  55. @{
  56. NodeName="*"
  57. PSDscAllowPlainTextPassword=$True
  58. PsDscAllowDomainUser=$True
  59. }
  60. )
  61. }
  62.  
  63. #$ConfigurationData.AllNodes += @{NewItem = "SomeNewValue"}
  64. #$ConfigurationData.AllNodes += @{AnotherNewItem = "Hello"}
  65.  
  66. foreach($Node in $ConfigurationData.AllNodes.GetEnumerator() | Where-Object{$_.NodeName -eq "*"})
  67. {
  68. $node.add("NewItem", "SomeNewValue")
  69. $node.add("AnotherNewItem", "Hello")
  70. }
  71.  
  72. $ConfigurationData | ConvertTo-Json
  73. {
  74. "AllNodes": [
  75. {
  76. "NodeName": "*",
  77. "PSDscAllowPlainTextPassword": true,
  78. "NewItem": "SomeNewValue",
  79. "AnotherNewItem": "Hello",
  80. "PsDscAllowDomainUser": true
  81. }
  82. ]
  83. }
  84.  
  85. $ConfigurationData.AllNodes.GetEnumerator() += @{"NewItem" = "SomeNewValue"}
  86.  
  87. $ConfigurationData = @{
  88. AllNodes = @(
  89. @{
  90. NodeName="*"
  91. PSDscAllowPlainTextPassword=$True
  92. PsDscAllowDomainUser=$True
  93. }
  94. )
  95. }
  96.  
  97. $ConfigurationData.AllNodes.GetEnumerator().Add("NewItem","SomeNewValue")
  98.  
  99. $ConfigurationData.AllNodes.GetEnumerator().Add("AnotherNewItem","Hello")
  100.  
  101. $ConfigurationData | ConvertTo-Json
  102.  
  103.  
  104.  
  105.  
  106. {
  107. "AllNodes": [
  108. {
  109. "NodeName": "*",
  110. "PSDscAllowPlainTextPassword": true,
  111. "NewItem": "SomeNewValue",
  112. "AnotherNewItem": "Hello",
  113. "PsDscAllowDomainUser": true
  114. }
  115. ]
  116. }
Add Comment
Please, Sign In to add comment