Fortinet Document Library

Version:


Table of Contents

Microsoft WinRM v1.0.2

1.0.2
Copy Link

About the connector

Microsoft Windows Remote Management (WinRM) enables you to remotely perform various management tasks, such as running batch scripts, PowerShell scripts, and uploading files.

Microsoft WinRM connector is for the WinRM service that allows you to invoke commands on targeted Windows machines from any machine that can run Python.

This document provides information about the Microsoft WinRM connector, which provides an interface to connect with a Windows server and remotely execute commands on a Microsoft WinRM server using FortiSOAR™ playbooks. Add the Microsoft WinRM connector as a step in FortiSOAR™ playbooks and perform automated operations, such as executing commands, PowerShell (PS) commands, and scripts, and uploading a script file to a windows machine.

Version information

Connector Version: 1.0.2

FortiSOAR™ Version Tested on: 6.0.0-790

Authored By: Fortinet

Certified: Yes

Release Notes for version 1.0.2

Following enhancements have been made to the Microsoft WinRM Connector in version 1.0.2:

  • Added the Run Inline Powershell Script operation and playbook.

Installing the connector

From FortiSOAR™ 5.0.0 onwards, use the Connector Store to install the connector. For the detailed procedure to install a connector, click here.
You can also use the yum command to install connectors. Connectors provided by FortiSOAR™ are delivered using a FortiSOAR™ repository. Therefore, you must set up your FortiSOAR™ repository and run the yum command as a root user to install connectors:

yum install cyops-connector-microsoft-winrm

Prerequisites to configuring the connector

  • You must have the username and password of the Windows server you want to connect to and perform automated operations.
  • To run a Powershell Command action, you must have Powershell version 3.0 and later installed on your instance.
  • To access the FortiSOAR™ UI, ensure that port 443 is open through the firewall for the FortiSOAR™ instance.
  • You must configure WinRM on the Windows server to which you want to connect and use this connector, see the following section for details.

Configuring WinRM on a Windows server

To use this connector, you must configure WinRM on the Windows server to which you want to connect. To configure WinRM, do the following:

  1. Run the following command to set the default WinRM configuration values:
    c:\> winrm quickconfig
  2. (Optional) Run the following command to check whether a listener is running, and verify the default ports:
    c:\> winrm e winrm/config/listener
    The default ports are 5985 for HTTP, and 5986 for HTTPS.
  3. Enable basic authentication on the WinRM service.
    1. Run the following command to check whether basic authentication is allowed.

      c:\> winrm get winrm/config/service

    2. Run the following command to enable basic authentication.
      c:\> winrm set winrm/config/service/auth @{Basic="true"}

  4. Run the following command to allow transfer of unencrypted data on the WinRM service.

    c:\> winrm set winrm/config/service @{AllowUnencrypted="true"}

  5. If the channel binding token hardening level of the WinRM service is set to strict, change its value to relaxed.

    c:\> winrm set winrm/config/service/auth @{CbtHardeningLevel="relaxed"}

  6. Enable basic authentication on the WinRM client.

    1. Run the following command to check whether basic authentication is allowed.

      c:\> winrm get winrm/config/client

    2. Run the following command to enable basic authentication.

      c:\> winrm set winrm/config/client/auth @{Basic="true"}

  7. Run the following command to allow the transfer of unencrypted data on the WinRM client.

    c:\> winrm set winrm/config/client @{AllowUnencrypted="true"}

  8. If the WinRM host machine is in an external domain, run the following command to specify the trusted hosts.

    c:\> winrm set winrm/config/client @{TrustedHosts="host1, host2, host3"}

  9. Run the following command to test the connector to the WinRM service.
    c:\> winrm identity -r:http://winrm_server:5985 -auth:basic -u:user_name -p:password -encoding:utf-8

Configuring the connector

For the procedure to configure a connector, click here.

Configuration parameters

In FortiSOAR™, on the Connectors page, click the Microsoft WinRM connector row (if you are in the Grid view on the Connectors page) and in the Configurations tab enter the required configuration details: 

Parameter Description
Username Username used to connect to the Windows server to which you will connect and perform automated operations.
Password Password used to connect to the Windows server to which you will connect and perform automated operations.
Verify SSL Specifies whether the SSL certificate for the server is to be verified or not.
By default, this option is set as True.

Actions supported by the connector

The following automated operations can be included in playbooks, and you can also use the annotations to access operations from FortiSOAR™ release 4.10.0 onwards:

Function Description Annotation and Category
Run Command Runs the command you specify on the windows machine you have specified. execute_command
Miscellaneous
Run Powershell Command Runs the Powershell command you specify on the windows machine you have specified. execute_command
Miscellaneous
Run Inline Powershell Script Runs a series of Powershell commands you specify that can execute multiple lines of Powershell, without requiring the script to be saved as an "Attachment" record, on the windows machine you have specified. execute_ps_script
Miscellaneous
Run Script Runs the script that is saved as an "Attachment" record on the windows machine you have specified. execute_command
Miscellaneous
Upload File To Endpoint Uploads the provided script file to the location you specify on the windows machine you have specified. upload_file_to_endpoint
Miscellaneous

operation: Run Command

Input parameters

Parameter Description
Command Command that you want to execute remotely.
IP Address IP address of the windows machine on which you want to execute the command.
Protocol Protocol used for the remote connection, choose between http or https.
Port (Optional) Port number used for connecting to the Windows server.
Default port for http is 5985, and the default port for https is 5986.

Output

The JSON output contains the output of the command, which is dependent on the command that you execute.

The output contains the following populated JSON schema:
{
     "op_result": "",
     "op_status": ""
}

operation: Run Powershell Command

Input parameters

Parameter Description
Command Powershell command that you want to execute remotely.
IP Address IP address of the windows machine on which you want to execute the command.
Protocol Protocol used for the remote connection, choose between http or https.
Port (Optional) Port number used for connecting to the Windows server.
The default port for http is 5985, and the default port for https is 5986.
Convert to JSON Select this option to convert the command output to the JSON format.  
By default, this is set to True.

Output

The JSON output contains the output of the Powershell command, which is dependent on the command that you execute.

The output contains the following populated JSON schema:
{
     "op_result": "",
     "op_status": ""
}

operation: Run Inline Powershell Script

Input parameters

Parameter Description
Command Series of Powershell command(s) that you want to execute remotely.
This operation can that can execute multiple lines of Powershell, without requiring the script to be saved as an "Attachment" record.
IP Address IP address of the windows machine on which you want to execute the command(s).
Protocol Protocol used for the remote connection, choose between http or https.
Port (Optional) Port number used for connecting to the Windows server.
The default port for http is 5985, and the default port for https is 5986.

Output

The output contains the following populated JSON schema:
{
     "op_result": "",
     "op_status": ""
}

operation: Run Script

Input parameters

Parameter Description
Attachment IRI Attachment IRI of the script file which is used to submit files directly from the FortiSOAR™ Attachments module to the Windows server.
IP Address IP address of the windows machine on which you want to execute the script.
Protocol Protocol used for the remote connection, choose between http or https.
Port (Optional) Port number used for connecting to the Windows server.
The default port for http is 5985, and the default port for https is 5986.

Output

The JSON output contains the output of the script, which is dependent on the script that you execute.

The output contains the following populated JSON schema:
{
     "op_result": "",
     "op_status": ""
}

operation: Upload File To Endpoint

Input parameters

Parameter Description
Absolute File Path Complete location on the windows machine where you want to save the script file.
Attachment IRI Attachment IRI of the script file which is used to upload files directly from the FortiSOAR™ Attachments module to the Windows server.
IP Address IP address of the windows machine to which you want to upload the PS script.
Protocol Protocol used for the remote connection, choose between http or https.
Port (Optional) Port number used for connecting to the Windows server.
Default port for http is 5985, and the default port for https is 5986.

Output

The JSON output contains a Success message and the location of where the script is uploaded if the script file is uploaded successfully or an Error message containing the reason for failure.

No output schema is available at this time.

Included playbooks

The Sample - Microsoft WinRM - 1.0.2 playbook collection comes bundled with the Microsoft WinRM connector. This playbook contains steps using which you can perform all supported actions. You can see the bundled playbooks in the Automation > Playbooks section in FortiSOAR™ after importing the Microsoft WinRM connector.

  • Run Command
  • Run Inline Powershell Script
  • Run Powershell Command
  • Run Script
  • Upload File To Endpoint

Note: If you are planning to use any of the sample playbooks in your environment, ensure that you clone those playbooks and move them to a different collection since the sample playbook collection gets deleted during connector upgrade and delete.

About the connector

Microsoft Windows Remote Management (WinRM) enables you to remotely perform various management tasks, such as running batch scripts, PowerShell scripts, and uploading files.

Microsoft WinRM connector is for the WinRM service that allows you to invoke commands on targeted Windows machines from any machine that can run Python.

This document provides information about the Microsoft WinRM connector, which provides an interface to connect with a Windows server and remotely execute commands on a Microsoft WinRM server using FortiSOAR™ playbooks. Add the Microsoft WinRM connector as a step in FortiSOAR™ playbooks and perform automated operations, such as executing commands, PowerShell (PS) commands, and scripts, and uploading a script file to a windows machine.

Version information

Connector Version: 1.0.2

FortiSOAR™ Version Tested on: 6.0.0-790

Authored By: Fortinet

Certified: Yes

Release Notes for version 1.0.2

Following enhancements have been made to the Microsoft WinRM Connector in version 1.0.2:

Installing the connector

From FortiSOAR™ 5.0.0 onwards, use the Connector Store to install the connector. For the detailed procedure to install a connector, click here.
You can also use the yum command to install connectors. Connectors provided by FortiSOAR™ are delivered using a FortiSOAR™ repository. Therefore, you must set up your FortiSOAR™ repository and run the yum command as a root user to install connectors:

yum install cyops-connector-microsoft-winrm

Prerequisites to configuring the connector

Configuring WinRM on a Windows server

To use this connector, you must configure WinRM on the Windows server to which you want to connect. To configure WinRM, do the following:

  1. Run the following command to set the default WinRM configuration values:
    c:\> winrm quickconfig
  2. (Optional) Run the following command to check whether a listener is running, and verify the default ports:
    c:\> winrm e winrm/config/listener
    The default ports are 5985 for HTTP, and 5986 for HTTPS.
  3. Enable basic authentication on the WinRM service.
    1. Run the following command to check whether basic authentication is allowed.

      c:\> winrm get winrm/config/service

    2. Run the following command to enable basic authentication.
      c:\> winrm set winrm/config/service/auth @{Basic="true"}

  4. Run the following command to allow transfer of unencrypted data on the WinRM service.

    c:\> winrm set winrm/config/service @{AllowUnencrypted="true"}

  5. If the channel binding token hardening level of the WinRM service is set to strict, change its value to relaxed.

    c:\> winrm set winrm/config/service/auth @{CbtHardeningLevel="relaxed"}

  6. Enable basic authentication on the WinRM client.

    1. Run the following command to check whether basic authentication is allowed.

      c:\> winrm get winrm/config/client

    2. Run the following command to enable basic authentication.

      c:\> winrm set winrm/config/client/auth @{Basic="true"}

  7. Run the following command to allow the transfer of unencrypted data on the WinRM client.

    c:\> winrm set winrm/config/client @{AllowUnencrypted="true"}

  8. If the WinRM host machine is in an external domain, run the following command to specify the trusted hosts.

    c:\> winrm set winrm/config/client @{TrustedHosts="host1, host2, host3"}

  9. Run the following command to test the connector to the WinRM service.
    c:\> winrm identity -r:http://winrm_server:5985 -auth:basic -u:user_name -p:password -encoding:utf-8

Configuring the connector

For the procedure to configure a connector, click here.

Configuration parameters

In FortiSOAR™, on the Connectors page, click the Microsoft WinRM connector row (if you are in the Grid view on the Connectors page) and in the Configurations tab enter the required configuration details: 

Parameter Description
Username Username used to connect to the Windows server to which you will connect and perform automated operations.
Password Password used to connect to the Windows server to which you will connect and perform automated operations.
Verify SSL Specifies whether the SSL certificate for the server is to be verified or not.
By default, this option is set as True.

Actions supported by the connector

The following automated operations can be included in playbooks, and you can also use the annotations to access operations from FortiSOAR™ release 4.10.0 onwards:

Function Description Annotation and Category
Run Command Runs the command you specify on the windows machine you have specified. execute_command
Miscellaneous
Run Powershell Command Runs the Powershell command you specify on the windows machine you have specified. execute_command
Miscellaneous
Run Inline Powershell Script Runs a series of Powershell commands you specify that can execute multiple lines of Powershell, without requiring the script to be saved as an "Attachment" record, on the windows machine you have specified. execute_ps_script
Miscellaneous
Run Script Runs the script that is saved as an "Attachment" record on the windows machine you have specified. execute_command
Miscellaneous
Upload File To Endpoint Uploads the provided script file to the location you specify on the windows machine you have specified. upload_file_to_endpoint
Miscellaneous

operation: Run Command

Input parameters

Parameter Description
Command Command that you want to execute remotely.
IP Address IP address of the windows machine on which you want to execute the command.
Protocol Protocol used for the remote connection, choose between http or https.
Port (Optional) Port number used for connecting to the Windows server.
Default port for http is 5985, and the default port for https is 5986.

Output

The JSON output contains the output of the command, which is dependent on the command that you execute.

The output contains the following populated JSON schema:
{
     "op_result": "",
     "op_status": ""
}

operation: Run Powershell Command

Input parameters

Parameter Description
Command Powershell command that you want to execute remotely.
IP Address IP address of the windows machine on which you want to execute the command.
Protocol Protocol used for the remote connection, choose between http or https.
Port (Optional) Port number used for connecting to the Windows server.
The default port for http is 5985, and the default port for https is 5986.
Convert to JSON Select this option to convert the command output to the JSON format.  
By default, this is set to True.

Output

The JSON output contains the output of the Powershell command, which is dependent on the command that you execute.

The output contains the following populated JSON schema:
{
     "op_result": "",
     "op_status": ""
}

operation: Run Inline Powershell Script

Input parameters

Parameter Description
Command Series of Powershell command(s) that you want to execute remotely.
This operation can that can execute multiple lines of Powershell, without requiring the script to be saved as an "Attachment" record.
IP Address IP address of the windows machine on which you want to execute the command(s).
Protocol Protocol used for the remote connection, choose between http or https.
Port (Optional) Port number used for connecting to the Windows server.
The default port for http is 5985, and the default port for https is 5986.

Output

The output contains the following populated JSON schema:
{
     "op_result": "",
     "op_status": ""
}

operation: Run Script

Input parameters

Parameter Description
Attachment IRI Attachment IRI of the script file which is used to submit files directly from the FortiSOAR™ Attachments module to the Windows server.
IP Address IP address of the windows machine on which you want to execute the script.
Protocol Protocol used for the remote connection, choose between http or https.
Port (Optional) Port number used for connecting to the Windows server.
The default port for http is 5985, and the default port for https is 5986.

Output

The JSON output contains the output of the script, which is dependent on the script that you execute.

The output contains the following populated JSON schema:
{
     "op_result": "",
     "op_status": ""
}

operation: Upload File To Endpoint

Input parameters

Parameter Description
Absolute File Path Complete location on the windows machine where you want to save the script file.
Attachment IRI Attachment IRI of the script file which is used to upload files directly from the FortiSOAR™ Attachments module to the Windows server.
IP Address IP address of the windows machine to which you want to upload the PS script.
Protocol Protocol used for the remote connection, choose between http or https.
Port (Optional) Port number used for connecting to the Windows server.
Default port for http is 5985, and the default port for https is 5986.

Output

The JSON output contains a Success message and the location of where the script is uploaded if the script file is uploaded successfully or an Error message containing the reason for failure.

No output schema is available at this time.

Included playbooks

The Sample - Microsoft WinRM - 1.0.2 playbook collection comes bundled with the Microsoft WinRM connector. This playbook contains steps using which you can perform all supported actions. You can see the bundled playbooks in the Automation > Playbooks section in FortiSOAR™ after importing the Microsoft WinRM connector.

Note: If you are planning to use any of the sample playbooks in your environment, ensure that you clone those playbooks and move them to a different collection since the sample playbook collection gets deleted during connector upgrade and delete.