I would like to schedule one of our custom site task, for ex. (AIXHCZ009-Check Status of all Components in Server) via REST API call or by command line, instead of using via BigFix Console. The Execution Constraints like “Starts on” and “Ends on” will be future dates. How to schedule the action.
Thanks and appreciate any help.
Hi, within the XML you post to create the action (documentation) you need to expand the settings element and include the settings you would like - the subelements are StartDateLocalOffset/EndDateLocalOffset or StartDateTimeOffset/EndDateTimeOffset depending if you want it in local time or UTC.
I do this same thing with a VBscript that I wrote some time ago.
First, get the offset based on the timezone of the computer running the script:
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem")
For Each objItem In colItems
strOffset = objItem.CurrentTimeZone / 60
Exit For
Next
if (strOffset < 0) then
strOffset = strOffset * -1
if (strOffset < 10) then
strOffset = "-0" & left(stroffset & "000", 3)
else
strOffset = "-" & left(stroffset & "0000", 4)
end if
else
if (strOffset < 10) then
strOffset = "+0" & left(stroffset & "000", 3)
else
strOffset = "+" & left(stroffset & "0000", 4)
end if
end if
Once the start and end times/dates for the task has been determined, build the start & end strings.
strStartTime = GetDateFormat(right("00" & intStartDay, 2) & " " & MonthName(month(now()), true) & " " & year(now()) & " " & right("00" & intStartHour, 2) & ":" & right("00" & intStartMinute, 2) & ":00 " & strOffset)
strEndTime = GetDateFormat(right("00" & intEndDay, 2) & " " & MonthName(month(now()),true) & " " & year(now()) & " " & right("00" & intEndHour, 2) & ":" & right("00" & intEndMinute, 2) & ":00 " & strOffset)
Function GetDateFormat(ByVal Date1)
restURL = "https://bigfix:52311/api/query?relevance=" & urlencode("(format " & chr(34) & "P{0}DT{1}H{2}M{3}S" & chr(34) & " + it / (1*day) of it + it mod (1*day) / (1*hour) + it mod (1*hour) / (1*minute) + it mod (1*minute) / (1*second) ) of (" & chr(34) & Date1 & chr(34) & " as time - now)")
restReq.open "GET", restURL, false, restUsername, restPassword
restReq.send
Set strDoc = CreateObject("MSXML2.DOMDocument")
strDoc.setProperty "SelectionLanguage", "XPath"
strDoc.async = False
strDoc.loadXML(restReq.responseText)
Set colPatchNodes = strDoc.getElementsByTagName("Answer")
For Each strValue2 In colPatchNodes
strValue2 = split(strValue2.text, " ", 2)
GetDateFormat = strValue2(0)
next
End Function
The strStartTime and strEndTime strings are then used in the XML like ageorgiev wrote.
Hi,
Thanks for the procedure. I have exported already scheduled action as .bes from BigFix console and renamed as Action**.xml** file. Then updated date and time as “<StartDateTimeLocal>” instead of <StartDateTimeLocalOffset> in <Settings>
I have some PowerShell code I use to create the action start/end time in the format for the XML. Say you want to start/end the action on Oct 2nd at 17:00 UTC, this calculates the time offset that needs to be used in the XML