Following is a sample of a powershell script that runs fine from the powershell command line but not from within a FIM PowerShell Workflow Activity. Note that the “solaris” session specified in the snippet below is defined in PuTTY with applicable IP address. During execution of the workflow, the script does run up until the last line (it does some log file writing and some other processing not reflected in the snippet below). The last line is an attempt to logon to a remote machine and execute MyScript.sh. MyScript.sh never gets executed.
Additionally, the rest of the workflow that follows this PowerShell Workflow Activity ALSO never executes. Thus it appears that the script below hangs on the last line. I thought adding the –batch would alleviate this, but not so. Again the script runs fine from the powershell command line.
……………………………………………………………………………………………………………………………………………
Param
(
[String]$USERID,
[String]$USERNAME
)
$myApp = "D:\plink.exe"
[Array] $Creds = ("root", "<root-password>"), ("sysadmin", "<sysadmin-password>")
$sshcommand = & $myApp -load solaris -batch -l $Creds[0][0] -pw $Creds[0][1] /root/SOFTWARE/MyScript.sh $USERID $USERNAME
Return ""
……………………………………………………………………………………………………………………………………………
I replaced the last line with the following and got the same results:
D:\plink.exe -batch -load solaris -l $Creds[0][0] -pw $Creds[0][1] /root/SOFTWARE/MyScript.sh $USERID $USERNAME
I tested initiating this script from the FIM workflow activity using both the “Read from File” option and the “Include in Workflow Definition” option. I get the same results either way.
I noted that the command line was running PowerShell Version 3.0, while FIM was running Version 2.0. I tested running this script from the command line as both Version 2.0 and Version 3.0, and it works successfully in both cases. Thus the issue does not appear to be related to the version of PowerShell that FIM is running per se. I understand that PowerShell 3.0 requires .NET Framework 4.0 and that the FIM Service runs on the 3.5 Framework, so perhaps the issue is related to these differences?
Any thoughts on what may be causing this issue and how to resolve? Does FIM perhaps not support Plink? I appreciate that the issue might not have anything do with FIM and may just be powershell-specific, so I am posting on a powershell forum as well. But also posting here in case anyone has seen this with FIM and been able to resolve. Thanks for any ideas!
Ramona Balke