# Shutdown a Windows server

**URL:** <https://forum.ansible.com/t/shutdown-a-windows-server/24083>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [March 28, 2017, 3:51pm UTC](https://forum.ansible.com/t/shutdown-a-windows-server/24083 "2017-03-28T15:51:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MKPhil](https://avatars.discourse-cdn.com/v4/letter/m/9e8a1a/32.png) [@MKPhil](https://forum.ansible.com/u/MKPhil)\
**Post date:** [March 28, 2017, 3:51pm UTC](https://forum.ansible.com/t/shutdown-a-windows-server/24083/1 "2017-03-28T15:51:39Z")

</div>

I’m trying to create a Playbook to **_Shutdown_** a Windows server. I am aware of win\_reboot but that does a **_Reboot_** (i.e. shutdown /r) - I want to do shutdown /s to turn a machine completely off. I’ve made a copy of win\_reboot.py and changed the Python code so it does a shutdown /s but when I call it, the playbook seems to think it’s a PowerShell command:  
“The term ‘/usr/bin/python’ is not recognized as the name of a cmdlet etc…”

I can use the raw module: raw: shutdown /s /t 2 but I’d prefer the variable and error handling of a module.

Any ideas?

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [March 29, 2017, 11:01pm UTC](https://forum.ansible.com/t/shutdown-a-windows-server/24083/2 "2017-03-29T23:01:11Z")

</div>

I just use

raw: Stop-Computer -Force

I guess you could wrap that in a module but I have not yet hit a situation where anything more is required.

Hope this helps,

Jon

---

<div class="post-metadata">

**Author:** ![Matt\_Davis](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@Matt\_Davis](https://forum.ansible.com/u/Matt_Davis)\
**Post date:** [March 30, 2017, 5:13pm UTC](https://forum.ansible.com/t/shutdown-a-windows-server/24083/3 "2017-03-30T17:13:41Z")

</div>

win\_reboot isn’t a module, it’s a Python action that runs on the controller- you have to stick it in an action\_plugins dir (not library, as I assume you did, since it looks like it’s trying to run the python code on the Windows target).

I don’t think we’d accept win\_shutdown as a discrete module, but I might consider a new “state” arg for win\_reboot that defaults to “rebooted” but would accept “shutdown” instead…

-Matt
