Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@crshnbrn66
Created January 23, 2017 23:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crshnbrn66/f9779247e5b3dc8709aa2f72b51095aa to your computer and use it in GitHub Desktop.
Save crshnbrn66/f9779247e5b3dc8709aa2f72b51095aa to your computer and use it in GitHub Desktop.
$tasks2add = $tasks = $null
$taskjson = @'
[
{
"taskId": "1",
"name": "Server-Scommaintenance",
"enabled": false,
"inputs": {
"servers": "$(serverMonitors) ",
"webMonitors": "$(webMonitors)",
"MinuteValue": "2000",
"maintValue": "inMaint"
}
},
{
"taskId": "2",
"name": "Server-Scommaintenance",
"enabled": false,
"inputs": {
"servers": "$(serverMonitors) ",
"webMonitors": "$(webMonitors)",
"emailusers": "$(ScomNotify)",
"MinuteValue": "2000",
"maintValue": "RemoveMaint"
}
}
]
'@
$tasks2add = $taskjson|convertfrom-json
$newArraylist = new-object System.Collections.Generic.List[system.object]
$newArraylist.Add((New-object pscustomobject ($tasks2add[0])))
$newArraylist.Add((New-object pscustomobject ($tasks2add[1])))
$newArraylist.Add((New-object pscustomobject ($tasks2add[0])))
$newArraylist.Add((New-object pscustomobject ($tasks2add[1])))
#$newArraylist.count
$newArraylist[0].enabled = $true
$newArraylist[1].enabled = $false
$newArraylist[2].enabled = $false
$newArraylist[3].enabled = $true
$newArraylist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment