ServiceNow - Delete files from CI using Mid Server
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2024 10:43 PM
Hello,
We want to delete files from a particular CI that is discovered by the Mid Server. We have the Mid Server credentials along with the CI names.
How can we achieve this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2024 11:31 PM
Hi, can u explain a little bit more about this requirement?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2024 12:01 AM
Hello,
We received alerts from particular source on the Service Now instance. These alerts contain system information and the paths of log files. We need to delete those logs from the system.
But, initially they provided us the mid server name and CI name and Path of log files to delete.
is it possible to delete files from C drive of CI ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2024 06:05 AM - edited ‎12-20-2024 01:29 AM
Okay ,if u have path for that file then u should use powershell script like:
$filePath = "C:\inetpub\logs\LogFiles\W3SVC1" //Define the file path to delete
if (Test-Path $filePath) {
Remove-Item $filePath -Force // Delete the file
Write-Output "File $filePath deleted successfully."
} else {
Write-Output "File $filePath does not exist."
}
and if u want to perform this through orchestration activity then,
goto Orchestration->Activity Designer Activity, and use the powershell command with stored activities,like:
var command = 'powershell.exe -File "C:\inetpub\logs\LogFiles\W3SVC1";
var probe = new SNC.PSProbe();
var output = probe.executeProbe('MidServerName', command, 'cred_name');
gs.print(output);
Hope this can help,Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2024 03:05 AM
Thank you for response.
Could you please explain more. As in this script configuration item name is not mentioned.