Skip to main content
DoubleD
New Member
May 14, 2019
Question

Shutdown Script via SSH

  • May 14, 2019
  • 2 replies
  • 5811 views

Hello everyone,

 

i am writing a Powershellscript which shuts down some machines. One of these is a Fortigate. 

So I establish a new SSH-Session and invoke the "execute Shutdown"-Command. But how can I confirm it with "y"?

 

Is there any "force"-command or something to work around the Shutdown-Confirmation?

 

When i do: 

Invoke-SSHCommand -SessionId 0 -Command "execute shutdown"
Invoke-SSHCommand -SessionId 0 -Command "y"

 

it doesn't work.

 

Thanks a lot,

 

DoubleD

    2 replies

    Markus_Zimmermann
    New Member
    December 10, 2020

    Hello DoubleD,

     

    i have the same problem. How did you solve the issue?

     

    Thank you in advance, Markus

    DoubleD
    DoubleDAuthor
    New Member
    December 10, 2020

    Hi Markus,

     

    just try it with a SSHStream:

     

    $SSHStream = New-SSHShellStream -Index 0

     

    $SSHStream.WriteLine("execute shutdown") $SSHStream.Read()

     

    regards,

     

    Dominik

    emnoc
    New Member
    December 10, 2020

    Did you look at adding the cmd option to set  Confirm:$false in your script?

     

    Ken Felix

    alagoutte
    New Member
    December 13, 2020

    May better to use directly API (with PoweFGT !) need only to found the API call for shutdown device