Solved

System Caller calling a Powershell script

  • 20 September 2019
  • 4 replies
  • 80 views

Badge

I'm trying to call a PowerShell script using the System Caller transformer. The syntax of the system caller command line is: C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -ExecutionPolicy Bypass -file "C:<path>powershell_script.ps1"

I'm using it to access ProjectWise and run some process. I have tested it with PowerShell and it only works with Admin rights. However it does not work within FME and does not recognize the Powershell module commands for ProjectWise. The error I get is:

'New-PWLogin : The term 'New-PWLogin' is not recognized as the name of a cmdlet, function, script file, or operable'

I have tried running the workbench with Admin rights but it still gives the same error.

icon

Best answer by wunderkind 25 September 2019, 04:47

View original

4 replies

Badge

shout-out to Shaun Dempsey for the PS script

Badge +16

Hi @wunderkind,

This is typical when FME cannot run the command. According to the documentation:

If paths contain spaces, enclose the path in double quotes, and only on Windows enclose the entire command in double quotes. For example:

""C:\\run me\\something.exe" -filepath "C:\\path here\\filename.txt""

Hope this helps,

Itay

Badge

Hi @wunderkind,

This is typical when FME cannot run the command. According to the documentation:

If paths contain spaces, enclose the path in double quotes, and only on Windows enclose the entire command in double quotes. For example:

""C:\\run me\\something.exe" -filepath "C:\\path here\\filename.txt""

Hope this helps,

Itay

Hi @Itay,

System Caller: Failed to Execute "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" -ExecutionPolicy Bypass -file "C:<path>powershell_script.ps1"

When I use : C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -ExecutionPolicy Bypass -file "C:<path>powershell_script.ps1", I get an error in loading the PowerShell command as described above so it seems that latter syntax works although invoking PowerShell with system caller but from the error I get it does not load the ProjectWise commands installed with the module called pwps_dab so I'm thinking this is more a PowerShell problem.

Badge

I have been able to resolve this issue:

It was related to the install of the PowerShell module.

1. Ensure you install the PowerShell module with Admin rights using the syntax:Update-Module pwps_dab -Verbose

2. Ensure the module installs to the location: C:\\Program Files\\WindowsPowerShell\\Modules (a directory named pwps_dab will be installed).

3. Ensure your 'PSModulePath' is referencing the above location.

This Bentley article was helpful:https://communities.bentley.com/products/projectwise/content_management/f/projectwise-powershell-extensions-forum/143840/update-we-have-changed-the-way-we-are-delivering-pwps_dab

 

Reply