Citect Scada 2018- How to execute a Windows PowerShell Script

Hi,

I want to insert a string variable to my powershell script and then execute the powershell script. 

I've tried following :

DDEWrite("PowerShell", "C:\netsim\GotoOpcBlock.PS1", "paramOpcAddress", "MAINRACK.R_SYSCON.B_NAME");

This seems to start the powershell but, a powershell window complains about "File cannot be loaded because running script is disabled on this system". 

When I run Get-ExecutionPolicy the status is "RemoteSigned". I have also installed latest Windows Powershell. If I execute the powershell script from Windows Explorer the script runs fine and does what its supposed to do. 

Parameter SECURITY-BlockExec is set to 0, Allow Exec = TRUE, Allow RPC = TRUE

I'm not sure DDEwrite is the right function to execute a powershell script, its the closes I have found so far.

Appreciate all inputs and guides on solving this. 

Thanks

Regards

Rune

  • UPDATES,

    I've made some progress. I'm able to start the Powershell script from Citect. I had to set the ExecutionPolicy in the Citect Scada Bin folder as well.

    I'm able to start my Powershell script with either of following functions.
    Exec("C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe C:\netsim\GotoOpcBlock.PS1");
    or
    DDEWrite("PowerShell", "C:\netsim\GotoOpcBlock2.PS1", "paramOpcAddress", Test\0002\PV60);

    However I'm still not able to write my string value into the script.

    The first line in my powershell script looks like this:
    param($paramSrcGapPath = 'C:\netsim\projects\VCS_Develop\VCS_Develop.101.GAP3', [string] $paramOpcAddress = '')

    It is the parameter $paramOpcAddress = '' that I want to write a string value into.

    Appreciate all inputs and guides on solving this.

    Thanks

    Regards

    Rune
  • If you want to pass Test\0002\PV60 as literal text then please enclose it in double quotes in your DDEWrite call.
  • Solved it by using the Exec function.

    GAPFilePath and GAPBlockName defined as String variables

    Exec("C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe C:\netsim\GotoOpcBlock2.PS1" + " " + GAPFilePath + " " + GAPBlockName);