How to create payload in ecc queue?

Sathwik1
Tera Expert

Can someone help me to create payload in ecc queue..

I need to pass a powershell command through payload  so that command can perform some action in the midserver.

1 ACCEPTED SOLUTION

@Sathwik1 

I wrongly copied these 2 lines

try this

var value = "Get-ChildItem –Path \\'C:\\SathwikFolder\\' -Recurse | Where-Object {($_.LastWriteTime -lt (Get-Date).AddDays(-10))} | Remove-Item";
var payload = '<?xml version="1.0" encoding="UTF-8"?><parameter name="name" value="' + value + '"></parameter>';

when I used this it didn't give me xml error

see output below

XML Error.gif

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

21 REPLIES 21

@Sathwik1 

why not do this?

1) add that powershell command in ps file and store in mid server

2) then use script shared in below link

Calling PowerShell script on MID server 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Already tried @Ankur Bawiskar , can you please try the same in your personal instance and please share here, so that it will be helpful to many people.. there are no proper docs/community articles related to it,,

@Sathwik1 

I cannot setup mid server on my machine so cannot check

what's the error when you used this script? also what's the error in the input record of ecc_queue

 

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Ankur Bawiskar 

attached the input response below... pls check and help.

<?xml version="1.0" encoding="UTF-8"?><results probe_time="0"><result command=""><stdout/><stderr/></result><parameters><parameter name="agent" value="mid.server.DevMID_ServerCluster1"/><parameter name="signature" value=""/><parameter name="response_to" value=""/><parameter name="from_sys_id" value=""/><parameter name="source" value=""/><parameter name="priority" value="2"/><parameter name="agent_correlator" value=""/><parameter name="processed" value=""/><parameter name="error_string" value=""/><parameter name="sys_id" value="b59330c14741453224d43b54e54d4378"/><parameter name="sequence" value="1864fae02f90000001"/><parameter name="from_host" value=""/><parameter name="sys_created_on" value="2023-02-14 11:27:29"/><parameter name="sys_domain" value="global"/><parameter name="name" value=""/><parameter name="topic" value="Command"/><parameter name="state" value="ready"/><parameter name="queue" value="output"/><parameter name="ecc_queue" value="b59330c14741453224d43b54e54d4378"/></parameters></results>

 

@Sathwik1 

are you sure your mid server is capable to run powershell scripts

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader