RESTAPI: Generate tasks to set client settings on target computer - Windows
Log In or Register to download the BES file, and more.

0 Votes

Versioning - This is the latest version.

1RESTAPI: Generate tasks to set client settings on target computer - Windows6/27/2015 4:43:18 PM
2RESTAPI: Generate tasks to set client settings on target computer - Windows10/18/2015 11:06:28 PM

Description

This task will generate uninstall tasks for all of the MSIs on the target computer in the same site as this task is run from using the current console operator username and password and the REST API. This task uses secure parameters so the password is encrypted.

 

References:

http://superuser.com/questions/149329/what-is-the-curl-command-line-syntax-to-do-a-post-request

https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/Tivoli%20Endpoint%20Manager/page/RESTAPI%20Task

https://github.com/bigfix/restapi-examples/tree/master/evaluate-relevance/cURL

http://bigfix.me/relevance/details/3002418

http://bigfix.me/relevance/details/3002370

http://bigfix.me/relevance/details/3002416

http://bigfix.me/relevance/details/3002416

 

Parameter Values:   (queried using JavaScript & console based session relevance)


Property Details

ID6254
StatusBeta - Preliminary testing ready for more
TitleRESTAPI: Generate tasks to set client settings on target computer - Windows
DomainBESC
CategoryConfiguration
Download Size0
Source IDjgstew
Source Release Date10/9/2014 12:00:00 AM
Added by on 10/18/2015 11:06:28 PM
Last Modified by on 10/18/2015 11:06:28 PM
Counters 2775 Views / 56 Downloads
User Rating 1 star 2 star 3 star 4 star 5 star * Average over 0 ratings. ** Log In or Register to add your rating.

Relevance

Windows Only (Relevance 2997197)
Used in 6450 fixlets and 32 analyses   * Results in a true/false
Show indented relevance
/* Windows Only */ windows of operating system
Used in 158 fixlets and 17 analyses   * Results in a true/false
Show indented relevance
/* Windows XP or Higher */ version of operating system >= "5.1"
BES Client is version 9+ (Relevance 2999387)
Used in 20 fixlets   * Results in a true/false
Show indented relevance
version of client >= "9.0" as version
Used in 2 fixlets   * Results in a true/false
Show indented relevance
not exists files whose(name of it starts with "RESTAPI_ImportedTasks_CS_" AND name of it as lowercase ends with ".log" AND (now - modification time of it < 7*day) ) of folder "__BESData\__Global\Logs" of parent folder of client

Actions

Action 1 (default)

Action Link Click here to deploy this action.
Script Type BigFix Action Script
// https://www.ibm.com/developerworks/community/wikis/home?lang=en#/wiki/Tivoli%20Endpoint%20Manager/page/Configuration%20Settings

// DEBUGGING: The following is for debugging
// appendfile {parameter "RootServerURL"}
// appendfile {parameter "currentSiteName"}
// appendfile {parameter "currentSiteType"}
// appendfile {parameter "currentConsoleUser"}
// move __appendfile __Download\parameters.txt
// parameter "secret" of action

// -- START:DOWNLOADS -------------------------

// - This is the commandline 7zip console which is use to unpack installers
// - https://www.virustotal.com/en/file/2a3afe19c180f8373fa02ff00254d5394fec0349f5804e0ad2f6067854ff28ac/analysis
prefetch 7za.zip sha1:9ce9ce89ebc070fea5d679936f21f9dde25faae0 size:384846 http://iweb.dl.sourceforge.net/project/sevenzip/7-Zip/9.20/7za920.zip

// - This unzip is a compiled verion of unzip v5.52 fom http://info-zip.org/
// - https://www.virustotal.com/en/file/8d9b5190aace52a1db1ac73a65ee9999c329157c8e88f61a772433323d6b7a4a/analysis
prefetch unzip.exe sha1:e1652b058195db3f5f754b7ab430652ae04a50b8 size:167936 http://software.bigfix.com/download/redist/unzip-5.52.exe

// Download CURL http://curl.haxx.se/download.html
// - Analysis of the CURL.exe inside: https://www.virustotal.com/en/file/7e4379dc72cc25e8d546b3f4b4305b93b6521aaae47c1ea2ee49e4cc4ce8b033/analysis/
prefetch curl.cab sha1:1d104ff75f52718709307ba03af0fcad17c1237a size:1435991 http://skanthak.homepage.t-online.de/download/curl-7.43.0.cab

// -- END:DOWNLOADS ---------------------------


// ADD TO UTILITY CACHE: unzip,7zip,curl
utility __Download\unzip.exe
utility __Download\7za.zip
utility __Download\curl.cab

// EXTRACT using unzip: the 7zip command line utility
waithidden __Download\unzip.exe -o "{ download path "7za.zip" }" 7za.exe -d "{ pathname of download folder }"

// EXTRACT using 7zip: CURL
waithidden "{ download path "7za.exe" }" e -i!I386\Curl.EXE -y -o"{ pathname of download folder }" "{ download path "curl.cab" }"

// VERIFY: Make sure the parameters are set
continue if { (parameter "currentSiteName" as trimmed string != "") AND (parameter "currentSiteType" as trimmed string != "") AND (parameter "RootServerURL" as trimmed string != "") }

// REST API - get all tasks in current site for de-duplication
waithidden "{ (pathname of file "Curl.EXE" of download folder) }" -k -o "{pathname of download folder}\Tasks_{parameter "currentSiteName"}.xml" --user {parameter "currentConsoleUser"}:{parameter "secret"} https://{parameter "RootServerURL"}/api/tasks/{parameter "currentSiteType"}/{parameter "currentSiteName"}

delete __createfile
delete ClientSettings_Tasks.bes

// CREATEFILE
createfile until END_OF_FILE
="1.0" encoding="UTF-8"?>
="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BES.xsd">
{ /* Generate Client Settings Tasks */ ( ("    Set %22" & (name of it) & "%22 to %22"& (value of it as trimmed string) &"%22 - UniversalThis task will set a client setting

This task was automatically generated using the task: "&"%22RESTAPI: Generate tasks to set client settings on target computer - Windows%22

 

%5d%5d>
TRUE"& "not exists settings %22" & name of it & "%22 whose(%22" & (value of it as trimmed string) & "%22 = value of it) of client" &"Configuration: Client Settings0RESTAPI: Generate tasks to set client settings on target computer - Windowshttps://forum.bigfix.com/users/jgstew" & ( ((year of it as string &"-"& month of it as two digits &"-"& day_of_month of it as two digits) of date (local time zone) of it) of now ) & "x-fixlet-modification-time" & (now as string) & "BESCClick here to set the Client Setting"& "setting %22" & (name of it) & "%22=%22" & (value of it as trimmed string) & "%22 on %22%7b parameter %22action issue date%22 of action%7d%22 for client" &"
") of (settings of client) whose( not exists ( (name of it & "=%22" & (value of it as trimmed string) & "%22"),( (concatenations "=" of substrings separated by "%22 to " of preceding text of last " - Universal" of following text of first "Set %22" of it) of node values of xpaths "/BESAPI/Task/Name/text()" of xml documents of files whose( (name of it as lowercase ends with ".xml") AND (exists lines whose(it as lowercase starts with "


END_OF_FILE

// (concatenations "=" of substrings separated by "%22 to " of preceding text of last " - Universal" of following text of first "Set %22" of it) of node values of xpaths "/BESAPI/Task/Name/text()" of xml documents of files whose( (name of it as lowercase ends with ".xml") AND (exists lines whose(it as lowercase starts with "

move __createfile __Download\ClientSettings_Tasks.bes

// Import UninstallMSI_Tasks.bes into custom site using API if there is at least one task inside (use secure parameter for user password)
if{ (exists files "ClientSettings_Tasks.bes" whose(exists contents whose(it contains "") of it) of download folders ) }
// IMPORT
    waithidden "{ (pathname of file "Curl.EXE" of download folder) }" -k -X POST -d @"{pathname of file "ClientSettings_Tasks.bes" whose(exists contents whose(it contains "") of it) of download folder}" --header "Content-Type:text/xml" -o "{(pathname of folder "__BESData\__Global\Logs" of parent folder of client)}\RESTAPI_ImportedTasks_CS_{parameter "currentSiteName"}.log" --user {parameter "currentConsoleUser"}:{parameter "secret"} https://{parameter "RootServerURL"}/api/tasks/{parameter "currentSiteType"}/{parameter "currentSiteName"}

endif

// VERIFY: Check if tasks were actually imported
// TODO: Need to add a check to see if the log file was created after the action started running (See adobe CC template for an example)
continue if{exists files whose((name of it = ("RESTAPI_ImportedTasks_CS_" & (parameter "currentSiteName") & ".log")) AND exists lines whose(it contains "") of it) of folder "__BESData\__Global\Logs" of parent folder of client}


// https://github.com/bigfix/restapi-examples/tree/master/evaluate-relevance/cURL
// curl --data-urlencode "relevance=RELEVANCE" --user username:password https://server:port/api/query
Success Criteria

This action will be considered successful when the applicability relevance evaluates to false.


Sharing

Social Media:
Share this page on Yammer

Comments

Log In or Register to leave comments!