Encountering error "Command failed (Substitution failed while writing file) createfile until END_OF_FILE" while executing Power shell script to install SNMP service

Hi All, Please assist me on the below mentioned error:-1:
Command failed (Substitution failed while writing file) createfile until END_OF_FILE.(In endpoint logs)

I am executing the below mentioned action script which includes the power shell script to install SNMP service on windows servers:-1:

delete __createfile
dos mkdir “C:\SNMP”

// CREATEFILE
CreateFile until END_OF_FILE

$check = Get-WindowsFeature | Where-Object {$_.Name -eq “SNMP-Services”}

If ($check.Installed -ne “True”) {

#Install/Enable SNMP Services

Add-WindowsFeature SNMP-Services | Out-Null

}

END_OF_FILE

delete powershell.ps1
move __CreateFile powershell.ps1
move “powershell.ps1” "C:\SNMP\powershell.ps1"
waithidden powershell -ExecutionPolicy Bypass -command C:\SNMP\powershell.ps1
folder delete C:\SNMP

Please let me know the corrections required. Thank you

1 Like

The actionscript is trying to perform relevance substitution on everything between the curly brackets.

You need to read up on how to escape those characters to suppress the substitution.

1 Like

I choose the below script and remove some comments but still the same :-1:

delete __createfile
dos mkdir “C:\SNMP”

// CREATEFILE
CreateFile until END_OF_FILE

$check = Get-WindowsFeature | Where-Object {$_.Name -eq “SNMP-Services”}

If ($check.Installed -ne “True”) {

Add-WindowsFeature SNMP-Services | Out-Null

}

END_OF_FILE

delete powershell.ps1
move __CreateFile powershell.ps1
move “powershell.ps1” "C:\SNMP\powershell.ps1"
waithidden powershell -ExecutionPolicy Bypass -command C:\SNMP\powershell.ps1
folder delete C:\SNMP

https://www-01.ibm.com/support/docview.wss?uid=swg21506259

Everywhere you have a {, you a need to escape it with a second { so BigFix doesn’t think you’re trying to do relevance substitution.

1 Like

I used the double curly braces and it executed the script but it did not add the SNMP as a feature in win server.

As already mentioned, you will need to escape the curtly braces in the powershell commands to avoid relevance substitution.

Maybe an alternate approach, which leverages the power of Bigfix’s ability to detect what systems need to run remeidial actions, would be to check if the feature is installed via relevance, that way only servers that are missing the service will be able to the fixlet action to to install it. Eg

Relevance
(windows of operating system) and (product type of operating system != nt workstation product type) and (not exists selects "* from Win32_ServerFeature where Name='SNMP Service'" of wmis)

ActionScript
action uses wow64 redirection false
waithidden powershell.exe -executionpolicy bypass -command "Add-WindowsFeature SNMP-Service | Out-Null"

2 Likes

Thank you, let me try and get back.

Nope, did not work :frowning:

The command does install the feature, this from my test server, though it requires a restart so might need some restart detection so the fixlet doesn’t misreport as failed while the InstallPending state is waiting for the system restart

Relevance
(windows of operating system) and (product type of operating system != nt workstation product type) and (not exists selects "* from Win32_ServerFeature where Name='SNMP Service'" of wmis) and (not pending restart "SMNP-Service")

Action
action uses wow64 redirection false
waithidden powershell.exe -executionpolicy bypass -command "Add-WindowsFeature SNMP-Service | Out-Null"
action requires restart "SMNP-Service"

3 Likes

Thank you, I will try and get back.