DeviceProcessEvents
| where Timestamp > ago(1d)
| where (FileName =~ "sc.exe" and ProcessCommandLine has "create" and ProcessCommandLine has "binPath")
or (FileName in~ ("powershell.exe", "pwsh.exe") and ProcessCommandLine has "New-Service")
| where ProcessCommandLine !has_any ("Microsoft", "Windows", "ProgramData\\Microsoft")
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine, InitiatingProcessFileName
| sort by Timestamp desc