How do I run a Powershell script in Control-M? - INCLUDES VIDEO

Version 4
    Share:|

    This document contains official content from the BMC Software Knowledge Base. It is automatically updated when the knowledge article is modified.


    PRODUCT:

    Control-M/Agent for UNIX and Microsoft Windows


    COMPONENT:

    Control-M/Agent for UNIX and Microsoft Windows


    APPLIES TO:

    All versions of Control-M/Agent for UNIX and Microsoft Windows Windows Only



    PROBLEM:

     

    - How do I run a Powershell script in Control-M?
    - How do I define a Control-M Job to run a Powershell script on the Control-M/Agent?

      

     

     


    CAUSE:

    Wrong Syntax used when running the PowerShell command


    SOLUTION:

     

    - Create an OS type job by setting the execution "What" field to "Command".
    - Use this syntax to run the PowerShell Script:  powershell -file script.ps parameters
       For example:  powershell -file C:\Scripts\Example_script.ps1 -drive C:\ -rootFolder Scripts\logs -fileType all
    - Depending on the user Windows PATH environment variable, the full path to the powershell executable may be needed as well as to execute the script successfully
      For example:  C:\Windows\System32\WindowsPowerShell\v1.0\powershell -file C:\Scripts\Example_script.ps1

    Additional Information:
    - Do work with the script developer to write the script and run it manually without Control-M so to ensure it will complete correctly
    - Control-M Support Team do not provide any support on scripting

      

    The following video demonstrates this solution:

                                   
    Other languages:Italiano

     


    Article Number:

    000103832


    Article Type:

    Solutions to a Product Problem



      Looking for additional information?    Search BMC Support  or  Browse Knowledge Articles