Support Forum
The Forums are a place to find answers on a range of Fortinet products from peers and product experts.
DoubleD
New Contributor

Shutdown Script via SSH

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

4 REPLIES 4
Markus_Zimmermann
New Contributor

Hello DoubleD,

 

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

 

Thank you in advance, Markus

DoubleD

Hi Markus,

 

just try it with a SSHStream:

 

$SSHStream = New-SSHShellStream -Index 0

 

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

 

regards,

 

Dominik

emnoc
Esteemed Contributor III

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

 

Ken Felix

PCNSE 

NSE 

StrongSwan  

PCNSE NSE StrongSwan
alagoutte
New Contributor III

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

Announcements

Select Forum Responses to become Knowledge Articles!

Select the “Nominate to Knowledge Base” button to recommend a forum post to become a knowledge article.

Labels
Top Kudoed Authors