Skip to content

Instantly share code, notes, and snippets.

@crshnbrn66

crshnbrn66/add-objects.ps1 Secret

Created Jan 23, 2017
Embed
What would you like to do?
$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
You can’t perform that action at this time.