Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ConfigurationData = @{
- AllNodes = @(
- @{
- NodeName="*"
- PSDscAllowPlainTextPassword=$True
- PsDscAllowDomainUser=$True
- }
- )
- }
- $ConfigurationData = @{
- AllNodes = @(
- @{
- NodeName="*"
- PSDscAllowPlainTextPassword=$True
- PsDscAllowDomainUser=$True
- NewItem = "SomeNewValue"
- AnotherNewItem = "Hello"
- }
- )
- }
- $ConfigurationData.AllNodes += @{NewItem = "SomeNewValue"}
- $ConfigurationData.AllNodes += @{AnotherNewItem = "Hello"}
- $ConfigurationData.AllNodes
- Name Value
- ---- -----
- NodeName *
- PSDscAllowPlainTextPassword True
- PsDscAllowDomainUser True
- NewItem SomeNewValue
- AnotherNewItem Hello
- $ConfigurationData | ConvertTo-Json
- {
- "AllNodes": [
- {
- "NodeName": "*",
- "PSDscAllowPlainTextPassword": true,
- "PsDscAllowDomainUser": true
- },
- {
- "NewItem": "SomeNewValue"
- },
- {
- "AnotherNewItem": "Hello"
- }
- ]
- }
- $ConfigurationData = @{
- AllNodes = @(
- @{
- NodeName="*"
- PSDscAllowPlainTextPassword=$True
- PsDscAllowDomainUser=$True
- }
- )
- }
- #$ConfigurationData.AllNodes += @{NewItem = "SomeNewValue"}
- #$ConfigurationData.AllNodes += @{AnotherNewItem = "Hello"}
- foreach($Node in $ConfigurationData.AllNodes.GetEnumerator() | Where-Object{$_.NodeName -eq "*"})
- {
- $node.add("NewItem", "SomeNewValue")
- $node.add("AnotherNewItem", "Hello")
- }
- $ConfigurationData | ConvertTo-Json
- {
- "AllNodes": [
- {
- "NodeName": "*",
- "PSDscAllowPlainTextPassword": true,
- "NewItem": "SomeNewValue",
- "AnotherNewItem": "Hello",
- "PsDscAllowDomainUser": true
- }
- ]
- }
- $ConfigurationData.AllNodes.GetEnumerator() += @{"NewItem" = "SomeNewValue"}
- $ConfigurationData = @{
- AllNodes = @(
- @{
- NodeName="*"
- PSDscAllowPlainTextPassword=$True
- PsDscAllowDomainUser=$True
- }
- )
- }
- $ConfigurationData.AllNodes.GetEnumerator().Add("NewItem","SomeNewValue")
- $ConfigurationData.AllNodes.GetEnumerator().Add("AnotherNewItem","Hello")
- $ConfigurationData | ConvertTo-Json
- {
- "AllNodes": [
- {
- "NodeName": "*",
- "PSDscAllowPlainTextPassword": true,
- "NewItem": "SomeNewValue",
- "AnotherNewItem": "Hello",
- "PsDscAllowDomainUser": true
- }
- ]
- }
Add Comment
Please, Sign In to add comment