Troubleshooting an Action Script

Hi Team:
Hope someone may be able to help. I am running this action script which creates a directory, copies a generic configuration file, edits thje configuration file, then determines a data center name based on the membership of the device to a group. The action script errors where indicated below, but I cannot figure out why. Any ideas?

dos echo Grafana Alloy Agent Install >>C:\Windows\Temp\BFGAAI.Log

//*****************************
//* Step 000
//*****************************
//* Download Package
prefetch 44c97947c0ed9de3f0c8b2725a8620b1c8b46689 sha1:44c97947c0ed9de3f0c8b2725a8620b1c8b46689 size:81501891 http://redacted:52311/Uploads/44c97947c0ed9de3f0c8b2725a8620b1c8b46689/GrafanaAlloyAgentforWindowsServerFamily.tmp sha256:e73993d7e4edf89d02a459a7259656cb29254c873d8147c53cfdfd9d0e97fa2d
extract 44c97947c0ed9de3f0c8b2725a8620b1c8b46689
dos echo Executed Step 000 >>C:\Windows\Temp\BFGAAI.Log

//*****************************
//* Step 001
//*****************************
//* Creates the Program Files directory if it does not exist
parameter “dirPath” = “C:\Program Files\GrafanaLabs\Alloy”
if {not exists folder (parameter “dirPath”)}
folder create (parameter “dirPath”)
endif
dos echo Executed Step 001 >>C:\Windows\Temp\BFGAAI.Log

//*****************************
//* Step 002
//*****************************
//* Configuration Template
parameter “sourceFilePath” = “C:\Program Files (x86)\BigFix Enterprise\BES Client__BESData\__Download\config.alloy”
parameter “destinationFilePath” = “C:\Program Files\GrafanaLabs\Alloy\config.alloy”
copy {parameter “sourceFilePath”} {parameter “destinationFilePath”}
dos echo Executed Step 002 >>C:\Windows\Temp\BFGAAI.Log

//*****************************
//* Step 003
//*****************************
//* Edit Configuration File (Hostname)
// Define the file path
parameter “filePath” = “C:\Program Files\GrafanaLabs\Alloy\config.alloy”
parameter “oldText” = “HOSTNAME”
parameter “computerName” = “{computer name}”
delete __appendfile
appendfile {concatenation “%0d%0a” of lines of file (parameter “filePath”)}
delete __replacefile
appendfile {concatenation “%0d%0a” of (if it = (parameter “oldText”) then (parameter “computerName”) else it) of lines of file (parameter “filePath”)}
delete (parameter “filePath”)
move __replacefile (parameter “filePath”)
dos echo Executed Step 003 >>C:\Windows\Temp\BFGAAI.Log

Error occurs at this step

//*****************************
//* Step 004
//*****************************
//* Set the Data Center value
if {member of group 719889 of sites} parameter “Data Center”=“NA_CDC”
elseif {member of group 719888 of sites} parameter “Data Center”=“NA_CDC”
elseif {member of group 719890 of sites} parameter “Data Center”=“NA_FH”
elseif {member of group 921552 of sites} parameter “Data Center”=“NA_OSH”
else parameter “Data Center” = “Not Specified”
endif
parameter “Alloy” = “C:\Program Files\GrafanaLabs\Alloy\config.alloy”
parameter “DC” = “DATACENTER_NAME”
delete __appendfile
appendfile {concatenation “%0d%0a” of lines of file (parameter “Alloy”)}
delete __replacefile
appendfile {concatenation “%0d%0a” of (if it = (parameter “DC”) then (parameter “Data Center”) else it) of lines of file (parameter “Alloy”)}
delete (parameter “Alloy”)
move __replacefile (parameter “Alloy”)
dos echo Executed Step 004 >>C:\Windows\Temp\BFGAAI.Log

//*****************************
//* Step 005
//*****************************
//* Install
wait __Download\alloy-installer-windows-amd64.exe /S
dos echo Executed Step 005 >>C:\Windows\Temp\BFGAAI.Log

Which specific line does the action error on?

I’m not certain; unable to determine, other than in Step 4

I think you need newlines after your ‘if’ and ‘elseif’ conditions, before running the commands for ‘parameter’

I like how you do your debugging.

Did you check the client log?

Will give that a try, thank you Jason!

I did; gave me nothing more than true/false on one line.

Thank you, by the way. Thought it would be a quick way to figure out where it’s failing

IN your client logs, you will be able to see the Parameters getting set, so this is a neat way to know “which step passed” in your troubleshooting.

In reading through step 4, I wonder if you are getting a relevance substitution error on

appendfile {concatenation “%0d%0a” of lines of file (parameter “Alloy”)}

in cases where the file is empty or missing?
Might want to put an existence check for the file?

1 Like