Overview

There are three methods available for using scripts in SMA:

  • Run a script or an executable located on a network path
  • Copy the script locally to the workstation

In this case, you must add the files to “Dependencies.”

  • Run an executable that is already on the workstation

Example 1: Retrieve User Profile Sizes

In the examples, the goal is to run a script to display the result in the inventory of each workstation.

Tool

VBS Script: GetSize

Script

  • Add the script to dependencies

Next, launch the VBS using KACE variables.

  • Directory: $(KACE_SYS_DIR) => Corresponds to c:\windows\system32
  • File: wscript.exe => I prefer wscript because it does not display a black (DOS) window on workstations, remember to remove all “wscript.echo”
  • Parameter: “$(KACE_DEPENDENCY_DIR)\Getsize.vbs” => Replace Getsize.vbs with your script. $(KACE_DEPENDENCY_DIR) refers to the folder where the script will be copied to the workstation

Custom Inventory

The script will create the file c:\Windows\temp\TailleProfils.log

  • Create a new software
  • Then enter the name (not very important) and the custom inventory rule
ShellCommandTextReturn(c:\windows\system32\cmd.exe /c type c:\Windows\temp\TailleProfils.log)

Another example

ShellCommandTextReturn(cmd /c findstr "Monitor Name";"Serial Number " C:\ProgramData\Dell\Kace\mon.mon)

Result

Once the script has been run on the workstation and the inventory update has been carried out, the information will be available in the workstation inventory.

Example 2: Retrieve HDD Information

Tool

A colleague gave me a small script to display disk information in KACE’s custom inventory.

Download

Script

  • Create a new script (do not forget to activate it) and then add the two files as dependencies
  • Then configure the script launch
  • Schedule or execute the KACE script, the file C:\Windows\HDD-Info-Analyser.txt should be present on workstations

Custom Inventory

  • Create a new software
  • Then enter the name (not very important) and the custom inventory rule
ShellCommandTextReturn(c:\windows\system32\cmd.exe /c type C:\Windows\HDD-Info-Analyser.txt)

Result

Once the script has been launched on the workstation and the inventory update has been performed, the information will be available in the workstation inventory.

Example 3: Retrieve Serial Numbers

The script will generate a text file c:\windows\temp\key.txt which will then be displayed in the inventory of each workstation where the script is run.

Tool

I will use the tool productkey which I will copy to \\K1000\clientdrop\Custom\GetSerial

Script

Next, I will use scripts to launch the tool.

Custom Inventory

Just display the text file in the workstation inventory.

ShellCommandTextReturn(c:\windows\system32\cmd.exe /c type c:\windows\temp\key.txt)

Result

Serial numbers are displayed in the workstation inventory.

Be aware: in case of workstation formatting, there will be no history of serial numbers.

Appendix

SMA Variable

Here is the link: quick-reference-to-scripts-variables or kb 111283

$(KACE_DEPENDENCY_DIR)This is the folder where any script dependencies for this script are downloaded to the client.5.2+ $(KACE_DATA_DIR)\packages\kbots\xxx.5.1 $(KACE_INSTALL)\packages\kbots\xxx.
$(KACE_INSTALL)$(KACE_INSTALL_DIR) $(KBOX_INSTALL_DIR)Installation directory for executables, scripts, packages, etc.All are synonymous. Preferred: $(KACE_INSTALL)5.2+ Win7/Vista C:\ProgramData\Dell\KACE5.2+ XP C:\Documents and Settings\All Users\Dell\KACE5.2+ Mac OS X /Library/Application Support/Dell/KACE/bin5.2+ Linux /opt/dell/kace5.1 Windows c:\Program Files\KACE\KBOX
$(KACE_SYS_DIR)$(KBOX_SYS_DIR)agent machine’s system directory.Both are synonymous. Preferred: $(KACE_SYS_DIR)Windows C:\Windows\System32Mac OS X /Linux /
$(KACE_MAC_ADDRESS)$(MAC_ADDRESS) $(KBOX_MAC_ADDRESS)agent machine’s primary ethernet MAC address.All are synonymous. Preferred: $(KACE_MAC_ADDRESS)
$(KACE_IP_ADDRESS)$(KBOX_IP_ADDRESS)agent’s local IP address (corresponds with network entry of KACE_MAC_ADDRESS) (http://kace.kbox.com:80)Both are synonymous. Preferred: $(KACE_IP_ADDRESS)
$(KACE_SERVER_URL)combination of server, port, and url prefix (http://kace.kbox.com:80)
$(KACE_SERVER)hostname of K1000 server. kbox
$(KACE_SERVER_PORT)port to use when connecting to the K1000 server. (80/443)
$(KACE_SERVER_URLPREFIX)web protocol to use when connecting to the K1000 server. (http/https)
$(KACE_COMPANY_NAME)agent’s copy of the setting from server’s config page
$(KACE_KUID)$(KBOX_MACHINE_ID)this is the unique Dell/KACE ID assigned to this agent.Both are synonymous. Preferred: $(KACE_KUID)
$(KACE_APP_DIR)Installation directory the Dell/KACE agent and plugins.for older agents this is mapped to: $(KACE_INSTALL)5.2+ Windows C:\Program Files\Dell\KACE or C:\Program Files (x86)\Dell\KACE5.2+ Mac OS X /Library/Application Support/Dell/KACE/bin5.2+ Linux /opt/dell/kace5.1 $(KACE_INSTALL)
$(KACE_DATA_DIR)Installation directory for executables, scripts, packages, etc.for older agents this is mapped to: $(KACE_INSTALL)5.2+ Win7/Vista C:\ProgramData\Dell\KACE5.2+ XP C:\Documents and Settings\All Users\Dell\KACE5.2+ Mac OS X /Library/Application Support/Dell/KACE/data5.2+ Linux /var/dell/kace5.1 $(KACE_INSTALL)
$(KACE_AGENT_VERSION)substitutes the version number of the installed agent. »5.2.12345″5.2+ Only
$(KACE_AGENT_ARCH)substitutes the architecture of the installed agent. »x86/x64″5.2+ Windows Only
$(KACE_HARDWARE_ARCH)substitutes the architecture of the physical hardware. »x86/x64″5.2+ Windows Only
$(KACE_OS_FAMILY)substitutes windows, mac, or linux depending on the operating system of the agent machine.5.2+ Only
$(KACE_OS_ARCH)substitutes x86 or x64 depending on the architecture of the installed version of Microsoft Windows.5.2+ Windows Only


0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.