News:

We really need your input in this questionnaire

Main Menu

Deleting files script

Started by dersonik, April 20, 2016, 11:26:40 AM

Previous topic - Next topic

dersonik

Is that possible to run the script from netxms to delete downloads folder (files inside downloads) in windows server 2012 ?

Victor Kirhenshtein

Hi,

yes, you can define action in agent (using Action or ActionShellExec entries in nxagentd.conf) and then define object tool to run it manually or server side action of type "execute action on remote agent" to run it automatically from event processing policy.

Best regards,
Victor

dersonik

Ok i'm using powershell with command:

ActionShellExec=cleandownloads:powershell -command "& ls ~\Downloads\ | remove-item -force -recurse"
and this command not working from netxms but working in powershell

i have too
ActionShellExec=cleantemp:powershell -command "& ls C:\Windows\TEMP\ | remove-item -force -recurse"
and this commands works fine form powershell and from agent


any ideas?

Victor Kirhenshtein

Hi,

I'm suppose ~ in ~\Downloads\ refers to home directory of the user - but if you run agent as a service it by default runs under local system account, so ~ points to completely different place.

Best regards,
Victor