1 Reply Latest reply on Jan 29, 2015 3:41 AM by Mike Jones

    How to save Powershell script output through NSH?

      Hello Everyone,

       

      I'm fairly new to powershell but I'd really like to try to get this script working.

       

      Currently I have my script running as a NSH Script job.

      cmd /c "powershell -InputFormat NONE

      cd C:

      function Some-Function {

      ...

      ...

      ..

      .

      }

      Some-Function -param value -param value -switch > output.txt"

       

      I would like to save the results of the script in a text document, preferably on the client pc or app server. The script runs fine on it's own, but when I run it as a job it's hard to tell if it's actually saving the output anywhere or if I'm just looking in the wrong places. Is there a better way for me to specify the path the output.txt to be saved?

        • 1. Re: How to save Powershell script output through NSH?
          Mike Jones

          Michell

           

          It depends on a couple of things where the output will be placed:

          1. If the redirect is within thepowershellscript then it will be local to the server that is running the script, so you can specify the path using windows standard paths > c:\temp\output.txt
          2. Type 1 NSH script the focus is managed server so something like nexec$NSH_RUNCMD_HOSTpowershell-InputFormat none -command "hostname" > /c/temp/output.txt - puts it in the temp drive on the managed server
          3. Type 2 NSH script runs on the app server so something like nexec $SERVER powershell -InputFormat none -command "hostname" > /tmp/output.txt - puts it in thetmpdrive on the app server


          Once you have the output file you could use  "blcli Email sendMailWithAttachment" to forward it on