Jump to content

PowerShell as "Run Command" - getting the results back


Recommended Posts

Hi all

We use the Run Command tasks extensively, for running stuff on client machines (currently around 1000 endpoints). Examples are to download an MSI from a website and then a second task to run msiexec. Other examples are to pull values from the registry and email them back for diagnostics. Whilst the editor doesn't lend itself to powershell scripts that require multiple steps, with no option to edit them properly, it generally does work.

But, what's the best way to return results from PowerShell? Because the task itself starts okay, the task execution history shows that the task executed, even if the powershell etc then failed.

My current scenario is this. I am downloading an MSI as one task, installing it as another task by utilising msiexec and specifiying a log file, and then have a third task to email me back the log file. Which is all VERY clunky.

Are there any viable alternative approaches?

Sample Run Command line:

powershell -Command "$secpasswd = ConvertTo-SecureString 'xxx' -AsPlainText -Force;$cred = New-Object System.Management.Automation.PSCredential ('xxx', $secpasswd);Invoke-WebRequest 'http://xxx/TeamViewer/xxx.mst' -OutFile 'C:\Windows\Temp\xxx.mst' -Credential $cred;Invoke-WebRequest 'http:/xxx/TeamViewer/TeamViewer_Host.msi' -OutFile 'C:\Windows\Temp\TeamViewer_Host.msi' -Credential $cred;msiexec /i 'C:\Windows\Temp\TeamViewer_Host.msi' ADDLOCAL="f.ProductFeature,f.ProgramMenuShortcut,f.ProgramMenuShortcut" TRANSFORMS='C:\Windows\Temp\xxx.mst' /qn /l*v 'C:\Windows\Temp\Jim.log'"






Link to comment
Share on other sites

  • 2 weeks later...
  • Administrators

Unfortunately I'm not well versed in PowerShell. It's rather a question for PowerShell experts in the appropriate (probably MS) forum.

Link to comment
Share on other sites

  • 3 weeks later...
  • ESET Moderators


Just saw the mention.  I will admit my PowerShell skills are pretty amateur, but since you are instantiating it from ESET PROTECT, I'm wondering if the "-command" argument is still needed.  You might want to check with business support on this and see what they advise.


Aryeh Goretsky

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...