#.
#   .--Security Warning----------------------------------------------------.
#   |               ____                       _ _                         |
#   |              / ___|  ___  ___ _   _ _ __(_) |_ _   _                 |
#   |              \___ \ / _ \/ __| | | | '__| | __| | | |                |
#   |               ___) |  __/ (__| |_| | |  | | |_| |_| |                |
#   |              |____/ \___|\___|\__,_|_|  |_|\__|\__, |                |
#   |                                                |___/                 |
#   |              __        __               _                            |
#   |              \ \      / /_ _ _ __ _ __ (_)_ __   __ _                |
#   |               \ \ /\ / / _` | '__| '_ \| | '_ \ / _` |               |
#   |                \ V  V / (_| | |  | | | | | | | | (_| |               |
#   |                 \_/\_/ \__,_|_|  |_| |_|_|_| |_|\__, |               |
#   |                                                 |___/                |
#   +----------------------------------------------------------------------+
#   |            Use this alert handler at your own risk!                  |
#   |         It can execute arbritrary code with permissions              |
#   |                of the configured windows user!                       |
#   '----------------------------------------------------------------------'



#.
#   .--Installation--------------------------------------------------------.
#   |         ___           _        _ _       _   _                       |
#   |        |_ _|_ __  ___| |_ __ _| | | __ _| |_(_) ___  _ __            |
#   |         | || '_ \/ __| __/ _` | | |/ _` | __| |/ _ \| '_ \           |
#   |         | || | | \__ \ || (_| | | | (_| | |_| | (_) | | | |          |
#   |        |___|_| |_|___/\__\__,_|_|_|\__,_|\__|_|\___/|_| |_|          |
#   |                                                                      |
#   +----------------------------------------------------------------------+
#   |                                                                      |
#   '----------------------------------------------------------------------'
Check_MK
1. Copy windows_remote to /opt/omd/sites/<mysite>/local/share/check_mk/alert_handlers
2. Copy windows_remote_alert_handler.py to /opt/omd/sites/<mysite>/local/share/check_mk/web/plugins/wato/
3. Install pypsrp into <mysite>: su - mystite; pip install pypsrp
4. Configure the alert handler rule in WATO/Alert Handlers, supply User, Password and command to execute

Windows
As user credentials are transferred via network, this alert handler is designed to use HTTPS as transport mode.
Therefore you have to enable the WinRM HTTPS listener on windows, at least with a self signed certificate.
For simplicity the certificate validation is set to false. To increase security you may enable validation and use 
valid public certificate chains instead

1. Create a self-signed certificate using administrative powershell:
 New-SelfSignedCertificate -DnsName <myhostname> -CertStoreLocation Cert:\LocalMachine\My
2. Create HTTPS listener and bind certificate to it using administrative cmd:
 winrm create winrm/config/Listener?Address=*+Transport=HTTPS @{Hostname="<myhostname>"; CertificateThumbprint="<thumbprint from step 1>"}
3. You may need to open the firewall. Also this will work in the NLA profiles "Domain" and "Private" only!


