invoke-sshcommand trying to see output – save output

Welcome Forums General PowerShell Q&A invoke-sshcommand trying to see output – save output

Viewing 2 reply threads
  • Author
    Posts
    • #247537
      Participant
      Topics: 6
      Replies: 8
      Points: 82
      Rank: Member

      Basically I am writing a script to clear the SEL logs on ESXi. I am trying to save output to a variable and be able to see that something actually did happen on the host. I have tried a few variations on what I have below but I am stumped. Just trying something simple like changing directories and output where I am at in the script. I SHOULD get back where I ‘CD’d to I assume(I commented that out, trying to store result in $result and output the result of the CD). Is this a variable scope thing? I just want to see that my commands are actually working before I move further.

    • #248056
      Senior Moderator
      Topics: 9
      Replies: 1309
      Points: 4,783
      Helping Hand
      Rank: Community Hero

      Just doing cd wil lnot give you any output, you have to use pwd to see where you are now. You can have “cd /var/log && pwd”

    • #248071
      Participant
      Topics: 8
      Replies: 567
      Points: 2,164
      Helping Hand
      Rank: Community Hero

      If you simply remove .output from your test, you’ll see there is not output but can confirm it did run the command

      [/crayon]

      You could check the exitstatus is equal to 0 instead.

      [/crayon]
Viewing 2 reply threads
  • You must be logged in to reply to this topic.