DX Infrastructure Manager

Expand all | Collapse all

Where is the dollar sign ($) conversion documented?

Jump to Best Answer
  • 1.  Where is the dollar sign ($) conversion documented?

    Posted 08-29-2018 04:24 PM

    I have created a very simple package with a custom probe as shown here:

     

    <package info>
       name = Training-Create_New_File
       description = Create a new file in C:\Temp, with a GUID for a file name.
       copyright = (C) Copyright 2018
       group = Training
       author = my_name
       date = 8/29/2018
       version = 1.0
       build = 5
       no_drop = no
    </package info>
    <SectionName>
       name = Training-Create_New_File
       type = simple
       OStype = windows
       OS = win64
       update = Training-Create_New_File
       <Training-Create_New_File>
          description = Generate a new file using PowerShell
          group = Training
          active = yes
          preserve_state = yes
          type = timed
          timespec = interval 10 min
          workdir =
          command = C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe
          arguments = -command { New-Item -Path "C:\Temp" -Name $((New-GUID).Guid) -ItemType File }
          config =
          logfile =
          datafile =
       </Training-Create_New_File>
    </SectionName>

     

    This command fails because the robot is altering the argument text by using 'MyStringExpand' to change variable names into values.  MyStringExpand thinks the dollar sign ($) is the beginning of a variable name, but cannot translate it, and throws the following error:

     

    Aug 29 15:36:00:496 [1880] Controller: --------------------------------------------------------------------------------------------------------
    Aug 29 15:36:00:496 [1880] Controller: ----- Robot controller 7.80 [Build 7.80.3132, Jun  1 2015] started -----
    Aug 29 15:36:00:496 [1880] Controller:  Name   = winrm, IP = IP, Port = 48000
    Aug 29 15:36:00:496 [1880] Controller:  OS     = Windows / Windows Server 2012 R2 Standard Evaluation, 64-bit / Service Pack 0 Build 9600
    Aug 29 15:36:00:496 [1880] Controller:  Domain = TheEvilNetwork
    Aug 29 15:36:00:496 [1880] Controller:  Primary HUB = /TheEvilNetwork/Nimsoft_hub/Nimsoft IP
    Aug 29 15:36:00:496 [1880] Controller:  Loglevel = 0, Logfile = controller.log
    Aug 29 15:36:00:496 [1880] Controller:  Running as user SYSTEM
    Aug 29 15:36:00:496 [1880] Controller: -----
    Aug 29 15:36:00:496 [1880] Controller: Controller on winrm port 48000 started
    Aug 29 15:36:01:497 [1880] Controller: Hub Nimsoft_hub(IP) contact established
    Aug 29 16:16:57:148 [1880] Controller: MyStringExpand - variable ((New-GUID).Guid) not found

     

    How can I disable this MyStringExpand functionality?

    Where is this translation functionality documented?

    How can I view which strings are available for expansion?



  • 2.  Re: Where is the dollar sign ($) conversion documented?

    Posted 08-29-2018 05:08 PM

    through out UIM the $ is used for variable names.

    this can not be disabled.

    the only information on the package editor is located here:

    packageEditor - CA Unified Infrastructure Management Probes - CA Technologies Documentation 



  • 3.  Re: Where is the dollar sign ($) conversion documented?

    Posted 08-29-2018 11:50 PM

    I'd suggest trying to escape the value - will take some trial and error:

     

    the short list of things I'd try

    $$

    %$

    %%$

    ^$

    ^$$

    \$

     

    -Garin



  • 4.  Re: Where is the dollar sign ($) conversion documented?
    Best Answer

    Posted 08-30-2018 09:58 AM

    Hi,

    I tested this with all the escape characters I could think of and couldn’t get it to work ☹ I guess that the $ is reserved for variables but the controller.

    So, I looked at using a bat file to execute this but again there are some difficulties and you need to have your command in a .ps1 file and call that from the .bat file and it does work   I am getting the guid file created every 10 mins in C:\Temp:

     

     

    Here is the Training-Create_New_File.ps1 file: 

    New-Item -Path "C:\Temp" -Name $((New-GUID).Guid) -ItemType File 

     

    Here is the Training-Create_New_File.bat file: 

    Powershell -ExecutionPolicy Bypass -File .\Training-Create_New_File.ps1 

     

    Here is the new package file with the new files added: 

     

    <package info>
    name = Training-Create_New_File
    description = Create a new file in C:\Temp, with a GUID for a file name.
    copyright = (C) Copyright 2018
    group = Training
    author = my_name
    date = 30/08/2018
    version = 1.0
    build = 3
    no_drop = no
    </package info>
    <Training-Create_New_File>
    name = Training-Create_New_File
    type = simple
    OStype = windows
    OS = win64
    update = Training-Create_New_File
    <files>
    <Training-Create_New_File.ps1>
    type = binary
    access = 0755
    dir = probes/training/training-create_new_file
    </Training-Create_New_File.ps1>
    <Training-Create_New_File.bat>
    type = script
    access = 0755
    dir = probes/training/training-create_new_file
    </Training-Create_New_File.bat>
    </files>
    <Training-Create_New_File>
    description = Create a new file in C:\Temp, with a GUID for a file name.
    group = Training
    active = yes
    preserve_state = yes
    type = timed
    timespec = interval 10 min
    workdir = probes/training/training-create_new_file
    command = Training-Create_New_File.bat
    arguments =
    config = Training-Create_New_File.cfg
    logfile = Training-Create_New_File.log
    datafile =
    </Training-Create_New_File>
    </Training-Create_New_File>

     

    You’ll need to create the Training-Create_New_File.ps1 and Training-Create_New_File.bat files and add them to your package. The package needs the workdir so it can find the files and the command is the Training-Create_New_File.bat file with no arguments. 

     

    I hope this helps.

     

    Steve D'Arcy



  • 5.  Re: Where is the dollar sign ($) conversion documented?

    Posted 08-30-2018 03:31 PM

    Excellent work and effort.  I took your lead and poked at it in an effort to slim down the configuration.  Eventually I was able to eliminate the use of the .bat file.

     

    <package info>
       name = Training-Create_New_File
       description = Create a new file in C:\Temp, with a GUID for a file name.
       copyright = (C) Copyright 2018
       group = Training
       author = gdececco
       date = 8/29/2018
       version = 1.2
       build = 19
       no_drop = no
    </package info>
    <SectionName>
       name = Training-Create_New_File
       type = simple
       OStype = windows
       OS = win64
       update = Training-Create_New_File
       <files>
          <Create-File.ps1>
             type = ascii
             access = 0777
             dir = probes/training/training-create_new_file
          </Create-File.ps1>
       </files>
       <Training-Create_New_File>
          description = Create a new file in C:\Temp, with a GUID for a file name.
          group = Training
          active = yes
          preserve_state = yes
          type = timed
          timespec = interval 1 min
          workdir = probes/training/training-create_new_file
          command = C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe
          arguments = -ExecutionPolicy Bypass -file Create-File.ps1
          config =
          logfile =
          datafile =
       </Training-Create_New_File>
    </SectionName>

     

    Create-File.ps1 Contents:

    New-Item -Path "C:\Temp" -Name $(([guid]::NewGuid()).Guid) -ItemType File | Out-Null;
    Return 0;

     

    This is probably as slim as I am going to get to running a PowerShell command without a lot of overhead.