ServiceNow TRICK: to get server level information from MID physical server without logging into it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2025 03:14 AM - edited ‎07-21-2025 12:18 AM
🖊📖...TRICK_AD_101...
We often need to do some server level activity on ServiceNow MID server physical box whether it is windows or Linux and to do so we experience lack of privilege to the physical box for login into there and run the commands. Most of the cases the reason is the server is maintained by separate Linux or Windows team who does not share any account credentials to get into the server following security concerns.
For some basic use case example, suppose we may need to check the Windows server's date/time or need to check some files or the list of files under 'MidServer/agent/' but we don't have the credentials to login to the server. In this case we can use mid server ecc queue to send the commands and mid server will get the information for us without login into the physical server.
For this we need to follow below steps suppose if we need to get the list of files under 'MidServer/agent/'.
Step 1: Go to 'Mid server capabilities'(ecc_agent_capability) table and add a capability as either 'PowerShell' (since we are considering Windows mid server) or 'All'.
Step 2: Navigate to MID Server> Script files and create a powershell script (.ps1) which will have the powershell commands/logic that we need to run into the server. Here is one script example to get the list of files under 'C:\MIDServer\agent\' folder.
Script Name: FilesUnderAgentFolder.ps1
Script:
$filePath = 'C:\MIDServer\agent\'
Get-childItem -Path $filePath
Step 3: Insert an entry in the ECC queue for mid server to execute what we are looking and get the expected output. Please see below SS for the entry which is processed. In the payload where the black empty box I marked there the script name needs to be put (here it should be 'FilesUnderAgentFolder.ps1'). For the other two black empty boxes I marked, one is for the mid server name in the 'agent' field and another is 'sequence' field that can be kept as it is set automatically.
Step 4: Once we see the output ECC queue record mentioned in step 3 is processed we can check the respective input entry payload in the ECC queue which will have the desired output that we are looking for.
This way we can run commands into the MID server physical box to get server level information we need without logging into the server and we don't need to rely on server team speeding up the process of getting information quickly. 🖋📔😊
Thanks,
Animesh Das
Happy learning and sharing!
You may mark this helpful as well if it helps you.