You can use Python to power off a Junos device from a Windows PC.
1. Install Python (Refer to PYEZ cookbook, link at the bootom)
2. Install Junos PYEZ library on Windows PC. (Refer to PYEZ cookbook, link at the bootom)
3. Open PowerShell and run the following commands, you can use the same in a Python script as well
4. Ensure netconf over ssh is enabled on SRX device
> show configuration system services netconf
ssh;
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
PS C:\Users\jnet> python
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import jnpr.junos
>>> from jnpr.junos import Device
>>> from jnpr.junos.exception import ConnectError
>>> srx=Device(host='<IP address of host>',user='root',password='password') << non-root should work if it has permissions.
>>> from jnpr.junos.utils.sw import SW
>>> srx.open()
Device(<IP>)
>>> sw=SW(srx)
>>> print(sw.poweroff())
Shutdown NOW!
[pid 98168]
>>> print(sw.poweroff())
>>Verification
Stopping cron.
.
Feb 24 20:24:58 jlaunchd: database-replication (PID 90347) terminate signal 15 sent
Feb 24 20:24:59 jlaunchd: ethernet-connectivity-fault-management (PID 90348) terminate signal 15 sent
Feb 24 20:24:59 jlaunchd: stats-agent (PID 90349) terminate signal 15 sent
Feb 24 20:25:00 jlaunchd: transport-control (PID 90350) terminate signal 15 sent
Feb 24 20:25:00 jlaunchd: SDN-Telemetry (PID 90353) terminate signal 15 sent
Feb 24 20:25:00 jlaunchd: routing (PID 90354) terminate signal 15 sent
Feb 24 20:25:01 jlaunchd: firewall (PID 90355) terminate signal 15 sent
Feb 24 20:25:01 jlaunchd: chassis-control (PID 90356) terminate signal 15 sent
Feb 24 20:25:01 jlaunchd: alarm-management (PID 90358) terminate signal 15 sent
Feb 24 20:25:05 jlaunchd: craft-control (PID 18017) exited with status=0 Normal Exit
Waiting (max 60 seconds) for system process `vnlru' to stop...done
Waiting (max 60 seconds) for system process `bufdaemon' to stop...done
Waiting (max 60 seconds) for system process `syncer' to stop...
Syncing disks, vnodes remaining...0 0 0 0 done
All buffers synced.
Uptime: 49d5h6m19s
besw0: 4 Broadcom SDK kernel threads killed
Khelp module "jsocket" can't unload until its refcount drops from 5 to 0.
The operating system has halted.
Turning the system power off.
>> Reference
https://www.juniper.net/us/en/training/jnbooks/day-one/automation-series/junos-pyez-cookbook/
https://junos-pyez.readthedocs.io/en/2.1.7/_modules/jnpr/junos/utils/sw.html
https://www.juniper.net/documentation/en_US/junos-pyez/topics/task/program/junos-pyez-device-rebooting.html