I'm experimenting with source controlling my SQL Agent Jobs & Schedules as .json files and deploying them with the dbatools SQL Agent command suite.
Given $sa = Get-Credential and foo.config of the below form...
{
"Schedule": "Foo",
"Disabled": false,
"FrequencyType": "Weekly",
"FrequencyInterval": "EveryDay",
"FrequencySubdayType": "Time",
"FrequencySubdayInterval": 0,
"FrequencyRelativeInterval": "Unused",
"FrequencyRecurrenceFactor": 1,
"StartDate": "20180823",
"EndDate": "20181023",
"StartTime": "070000",
"EndTime": "235959"
}
Attempting to use foo.config in a solution fails basic parsing with the following message:
~> $foo = Get-Content foo.config | ConvertFrom-Json
~> New-DbaAgentSchedule @foo -ServerInstance "." -SqlCredential $sa
WARNING: [15:50:04][New-DbaAgentSchedule] A schedule was not provided! Please provide a schedule name.
Well that sucks... Especially since the following works just fine...
$bar = @{
Schedule= "Foo"
Disabled= $false
FrequencyType= "Weekly"
FrequencyInterval= "EveryDay"
FrequencySubdayType= "Time"
FrequencySubdayInterval= 0
FrequencyRelativeInterval= "Unused"
FrequencyRecurrenceFactor= 1
StartDate= "20180823"
EndDate= "20181023"
StartTime= "070000"
EndTime= "235959"
}
New-DbaAgentSchedule @bar -ServerInstance "." -SqlCredential $sa
I really don't want to bother typing out each individual ... -Param1 $foo.Param1 -Param2 $foo.Param2 ... because I'm lazy. I would really much rather splat my config files into the various commands. Why won't this work!!?!1!
