I tried the same command on Linux and it works.
However, you don't really need to execute this housekeeping job. The Configuration Management Server automatically purge old XAlerts according to the value set on this EM system parameter:
XAlertsMaxAge: Determines, in days, how long XAlerts are saved before they are deleted by the Configuration Management Server
Use the CCM to change this EM system parameter to the desired value.
But thats it. Forgot that Parm. Had it already configured in the Past but with more days inside.
Ok, modified the Parm and the Script. Now it's ok.