- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2023 10:39 PM
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2023 02:16 AM
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
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2023 12:07 AM
tried like below @Ankur Bawiskar
that powershell script is responsible for deleting records in the mid server
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2023 12:32 AM
I tried as per your suggestion, but still it's not working.. please correct my code..
var gr = new GlideRecord('ecc_queue');
gr.newRecord();
gr.agent='mid.server.DevMID_ServerCluster1';
gr.topic='Command';
value = PowerShell -Command "Get-ChildItem –Path \"C:\SathwikFolder\" -Recurse | Where-Object {($_.LastWriteTime -lt (Get-Date).AddDays(-10))} | Remove-Item";
gr.payload = <?xml version="1.0" encoding="UTF-8"?><parameter name="name" value=+value/></parameter>;
gr.queue = "output";
gr.insert();
What was wrong in this @Ankur Bawiskar , please correct my code..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2023 12:56 AM
Please help me to understand what was mistake in the above code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2023 01:06 AM
I modified your script a little bit
please check the highlighted line and update it correctly
var gr = new GlideRecord('ecc_queue');
gr.initialize();
gr.agent='mid.server.DevMID_ServerCluster1';
gr.topic='Command';
var value = 'Get-ChildItem –Path \"C:\SathwikFolder\" -Recurse | Where-Object {($_.LastWriteTime -lt (Get-Date).AddDays(-10))} | Remove-Item';
gr.state = 'ready';
gr.payload = '<?xml version="1.0" encoding="UTF-8"?><parameter name="name" "value="' + value + '"/></parameter>';
gr.queue = "output";
gr.insert();
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2023 01:16 AM
Tried ankur, same error again..
In output, below part is highlighted in red.. I think there is some issue..