Changes to support PowerShell 3

Sep 24, 2012 at 7:05 PM


I added this change to get this running on PS 3...type accelerators and the "-registered" switch for Get-PSSnapin.


if(-not(Get-PSSnapin -Registered |? { $_.Name -eq 'FIMAutomation' })){ Add-PSSnapin FIMAutomation }

function Add-PSTypeAccelerator {
  [Parameter(Mandatory = $true)]
  [string] $AliasName,
  [Parameter(Mandatory = $true)]
  [string] $TypeName,
  [switch] $Force = $false
        $PSTypeAccelerators = [psobject].assembly.gettype("System.Management.Automation.TypeAccelerators")::Get
        $Type = Invoke-Expression "[$TypeName]"
 if ($PSTypeAccelerators.ContainsKey($AliasName))
  if ($Force)
   $PSTypeAccelerators.Remove($AliasName) | Out-Null
  } else
    throw 'Type accelerator "{0}" already exists.' -f $AliasName
 end {
  $PSTypeAccelerators.Add($AliasName, $Type)


Sep 24, 2012 at 7:15 PM

Thanks for the feedback!  I've already been using the activity with PowerShell 3.0 and have not had any issues. 

What advantage did you get from using the type accelerators?  Would love to hear more about it.


Sep 24, 2012 at 7:44 PM

I just realized that I pasted that into the wrong window.

Face meet palm. Palm, face.

Sep 24, 2012 at 10:54 PM

Too funny ;-)  Happy Accelerating!

Dec 9, 2012 at 7:46 AM


I'm trying to use this activity 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...

Have I missed something...?