1. Piklo

    Article: AN0001980Updated: 10.05.2021

    The programme Piklo enables execution of Powershell scripts. ObjectGears system contains number of functions for finding out information about systems in the network (computers, databases, programmes...) that are based on Powershell interface of the given system. You can also create your own scripts, execute them and import the acquired data into ObjectGears system.

    Piklo execution

    The programme Piklo can be executed in several way depending on the activation type - from the command line or by a script directly from ObjectGears.

    Execution format:

    Com.ObjectGears.Piklo.exe script_code [-type F|C] [-ident error_ident] [-config config_file] [par1 [par2 [par3 [...]]]]

    script_code - name of the script, that shall be executed (name of the file without suffix)

    type - type of the script execution

    F - The script will be saved on the disc and executed in Powershell as a separate process.

    C - The script will be executed directly by Piklo within current thread.

    ident - Identifier for one particular Piklo execution. Identifier is entered into the name of the error file for a better identification of an error from the given execution.

    config - Set up of a specific configuration file name

    config_file - Relative name of the configuration file in relation to executed Piklo.exe

    par1...parx - Parameteters passed to Piklo. Their meaning and number depends on the used script. The parameters are available in the script under variables $ScriptPar1...$ScriptParx.

    Return codes

    Code Description
    0 OK
    1 Script error. Description is in the file error...log
    2 Script name is not defined
    3 There is no file with script in the folder Scripts\__script_name__.ps1
    4 The name of the script cannot be "og"

    Execution from the command line

    Piklo is a stand-alone exe programme,  and so you can execute it by means of a command line, from a bat file, Powershell or you can schedule it as a job in Windows.

    In order the execute it you can use:

    Com.ObjectGears.Piklo.exe script_code

    Execution by a script from ObjectGears

    Piklo can be executed by means of ObjectGears script. However, execute it only from job or workflow. Execution e.g. from a button by HTTP request (access via web) does not need to be carried out properly. IIS may recycle the given service process and therefore Piklo may be prematurely terminated.

    In order to execute it use this function:

    int OG.Process.RunPiklo(string scriptName, string parameters);

    scriptName - name of the executed script (name of the file without suffix)

    parameters - parameters of the executed script

    return value - function returns the return code of Piklo programme

    Function RunPiklo executes Com.ObjectGears.Piklo.exe, that is in the folder given by the configuration parameter PikloDir (in web.config for web access or ObjectGearsService.exe.config for Windows service).

    A single script can be scheduled for multiple execution with different parameters by means of specifiing a configuration file in the parameter config with script execution. Example:

    a = OG.Process.RunPiklo('YourScriptName','-config \\yourserver\yourfolder\yourfile.config -type C');



    Piklo can be configured in two levels.

    The first configuration is carried out by means of file og_configuration.ps1 in the same folder like Piklo itself, which contains general parameters (e.g.: address to web service ObjectGears). This script is used for all Piklo scripts. If the file does not exist, it is ignored.

    The second level is configuration script specific for each particular script. This file is in the sam folder like Piko itself and it is called script_code.config. Here you can configure parameters specific for the given script. If the file does not exist, it is ignored.

    If you use parameter of the same name both in the file og_configuration.ps1 and in the file script_code.config, there will be value from the file kod_skriptu.config used in the script. Therefore, you can define a parameter used in a great part of scripts just once in one place in og_configuration.ps1. However, if you need for a particular script another value of this parameter, you can always correct it in the file script_code.config.

    Use the configuration files with UTF-8 encoding.

    A single script can be used for a multiple execution with various parameters by the means of setting up a specific configuration file name in the parameter config when the file is executed. Example:

    a = OG.Process.RunPiklo('YourScriptName','-config \\yourserver\yourfolder\yourfile.config -type C');


    Error log

    In case of an error in the script, the error is written into the file error_XXX.log, where XXX is name of of the executed script. However, if Piklo is executed with parameter ident, the name of the file is error_XXX_IDENT.log, where IDENT is value of the parameter ident.

    By setting up ident parameter you prevent overwriting the error file in case of a frequent execution of Piklo with the same script.

    User scripts

    Store your own scripts in the folder Scripts that is located in the same folder like the programme Piklo. There are same rules applicable for your script configuration and log like for ObjectGears system scripts.

    Do not start names of your scripts with characters OG in order that names do not collide with ObjectGears system scripts. Use the scripts with UTF-8 encoding.