none
PowerShell Workflow Activity using powershell v3 RRS feed

  • Question

  • Hi All,

    I'm using this PowerShell activity by CraigMartin in FIM R2 and would like to make use of PowerShell v3 functions like ConvertTo-Json... Any idea how I would go about getting this PowerShell activity to use PowerShell v3? I have installed v3 on my portal and FIM service servers, but the workflow keeps complaining that it doesn't understand convertTo-Json...

    Thx

    Q

    Saturday, December 8, 2012 10:32 PM

All replies

  • I don't believe you need to do anything. Only thing I can think of is you might need to load the module the command is in? See what $PSVersionTable looks like in your runspace also.

    My Book - Active Directory, 4th Edition
    My Blog - www.briandesmond.com

    Sunday, December 9, 2012 1:34 AM
    Moderator
  • Hi Brian,

    The results of $PSVersionTable:

    Name                           Value
    ----                           -----
    PSVersion                      3.0
    WSManStackVersion              3.0
    SerializationVersion           1.1.0.1
    CLRVersion                     4.0.30319.17929
    BuildVersion                   6.2.9200.16398
    PSCompatibleVersions           {1.0, 2.0, 3.0}
    PSRemotingProtocolVersion      2.2

    If I run the script from powershell, it works without a problem, if I copy the script as is into the workflow powershell activity, the event viewer reports the following:

    "PowerShell Activity

    The term 'ConvertTo-Json' is not recognized as the name of a cmdlet, function, script file, or operable program"

    I've even downloaded the source code, and recompiled it on my FIM server using the updated system.management assembly and .NET 4... same error.... I've also posted this question on codeplex and waiting fro Craig to respond... In the mean time if you have any other ideas... please let me know...

    Thx

    Q

    Sunday, December 9, 2012 8:52 AM
  • I also picked up in the Windows PowerShell event viewer the following event when the workflow kicks off:

    Provider "WSMan" is Started.

    Details:

    ProviderName=WSMan

    NewProviderState=Started

    SequenceNumber=1

    HostName=Default Host

    HostVersion=2.0

    HostId=b3971025-adb0-4bb7-a668-dab73268dc2f

    ........

    I see here Host version = 2.0.... but if you look at PSVersionTable host version is 3.0...

    Q

    Sunday, December 9, 2012 9:02 AM
  • I'm using this in production extensively with PSv3 and it's working fine so I'm not sure what's going on here. Try putting the script in a file on the file system and running it from there just in case this is an issue with the way the data returned from the portal is being parsed.

    My Book - Active Directory, 4th Edition
    My Blog - www.briandesmond.com

    Sunday, December 9, 2012 5:42 PM
    Moderator
  • Hey Brian,

    My script runs successfully from normal powershell, I then copy and paste it exactly like it is in the activity and when the workflow executes I still get "The term 'ConvertTo-Json' is not recognized as the name of a cmdlet, function, script file, or operable program"

    I will uninstall the activity and powershell and start from scratch... At least I know its working somewhere now so the problem must be on my server...

    Thx

    Will send feedback if I find anything.

    Q

    Sunday, December 9, 2012 8:11 PM