Home
%3CLINGO-SUB%20id%3D%22lingo-sub-974704%22%20slang%3D%22en-US%22%3E(WAL)%20%E2%80%93%20Workflow%20Example%20%E2%80%93%20Removal%20of%20a%20multivalued%20reference%20attribute%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-974704%22%20slang%3D%22en-US%22%3E%0A%20%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CSTRONG%3EFirst%20published%20on%20MSDN%20on%20Oct%2013%2C%202017%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%20Special%20Thanks%20to%20%3CSTRONG%3E%20Mr.%20David%20Hodge%20%3C%2FSTRONG%3E%20for%20putting%20the%20WAL%20Workflow%20Documentation%20together%20%3CBR%20%2F%3E%20Things%20to%20keep%20in%20mind%20%3CBR%20%2F%3E%20%E2%80%A2%20the%20RemoveValues%20function%20requires%20a%20%E2%80%9CList%E2%80%9D%20to%20be%20passed%20to%20it.%20Adding%20in%20the%20GUID%20into%20the%20RemoveValues%20function%20didn%E2%80%99t%20seem%20to%20do%20it.%20%3CBR%20%2F%3E%20%E2%80%A2%20An%20example%20PowerShell%20activity%20that%20allows%20you%20to%20build%20a%20list%20of%20object%20GUIDs%20to%20pass%20to%20the%20Update%20Resources%20activity.%20%3CBR%20%2F%3E%3CIMG%20alt%3D%22%22%20class%3D%22alignnone%20size-full%20wp-image-9606%22%20height%3D%22677%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F153938i661EDAED6E67D84D%22%20width%3D%22795%22%20%2F%3E%3CIMG%20alt%3D%22%22%20class%3D%22alignnone%20size-mediumlarge%20wp-image-9615%22%20height%3D%22573%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F153939i0358CF805F147BAD%22%20width%3D%22822%22%20%2F%3E%3CBR%20%2F%3EReferencing%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fsocial.technet.microsoft.com%2FForums%2Fen-US%2F63213b2d-4f31-416d-8e70-b871f37a7db8%2Fremovevaluesstringlist-not-removing-values%3Fforum%3DMimwal%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fsocial.technet.microsoft.com%2FForums%2Fen-US%2F63213b2d-4f31-416d-8e70-b871f37a7db8%2Fremovevaluesstringlist-not-removing-values%3Fforum%3DMimwal%3C%2FA%3E%20%3CBR%20%2F%3E%20Below%20is%20how%20I%20modified%20it%C3%A2%E2%82%AC%C2%A6%20We%20could%20probably%20be%20more%20elegant%20by%20add%20%3CBR%20%2F%3E%20function%20New-GenericObject%20%3CBR%20%2F%3E%20%7B%20%3CBR%20%2F%3E%20%26lt%3B%23%20%3CBR%20%2F%3E%20.Synopsis%20%3CBR%20%2F%3E%20Create%20a%20new%20generic%20object.%20%3CBR%20%2F%3E%20.Description%20%3CBR%20%2F%3E%20Create%20a%20new%20generic%20object.%20%3CBR%20%2F%3E%20.Example%20%3CBR%20%2F%3E%20New-GenericObject%20-TypeName%20System.Collections.Generic.List%26nbsp%3B%20-TypeParameters%20Microsoft.MetadirectoryServices.CSEntryChange%20%3CBR%20%2F%3E%20%23%26gt%3B%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%5BCmdletBinding()%5D%20%3CBR%20%2F%3E%20%5BOutputType(%5Bobject%5D)%5D%20%3CBR%20%2F%3E%20param(%20%3CBR%20%2F%3E%20%5Bparameter(Mandatory%20%3D%20%24true)%5D%20%3CBR%20%2F%3E%20%5Bstring%5D%20%3CBR%20%2F%3E%20%24TypeName%2C%20%3CBR%20%2F%3E%20%5Bparameter(Mandatory%20%3D%20%24true)%5D%20%3CBR%20%2F%3E%20%5Bstring%5B%5D%5D%20%3CBR%20%2F%3E%20%24TypeParameters%2C%20%3CBR%20%2F%3E%20%5Bparameter(Mandatory%20%3D%20%24false)%5D%20%3CBR%20%2F%3E%20%5Bobject%5B%5D%5D%20%3CBR%20%2F%3E%20%24ConstructorParameters%20%3CBR%20%2F%3E%20)%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20process%20%3CBR%20%2F%3E%20%7B%20%3CBR%20%2F%3E%20%24genericTypeName%20%3D%20%24typeName%20%2B%20'%60'%20%2B%20%24typeParameters.Count%20%3CBR%20%2F%3E%20%24genericType%20%3D%20%5BType%5D%24genericTypeName%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20if%20(!%24genericType)%20%3CBR%20%2F%3E%20%7B%20%3CBR%20%2F%3E%20throw%20%22Could%20not%20find%20generic%20type%20%24genericTypeName%22%20%3CBR%20%2F%3E%20%7D%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%23%20Bind%20the%20type%20arguments%20to%20it%20%3CBR%20%2F%3E%20%24typedParameters%20%3D%20%5Btype%5B%5D%5D%20%24TypeParameters%20%3CBR%20%2F%3E%20%24closedType%20%3D%20%24genericType.MakeGenericType(%24typedParameters)%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20if%20(!%24closedType)%20%3CBR%20%2F%3E%20%7B%20%3CBR%20%2F%3E%20throw%20%22Could%20not%20make%20closed%20type%20%24genericType%22%20%3CBR%20%2F%3E%20%7D%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%23%20Create%20the%20closed%20version%20of%20the%20generic%20type%2C%20don't%20forget%20comma%20prefix%20%3CBR%20%2F%3E%20%2C%5BActivator%5D%3A%3ACreateInstance(%24closedType%2C%20%24constructorParameters)%20%3CBR%20%2F%3E%20%7D%20%3CBR%20%2F%3E%20%7D%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%24MembersToAdd%20%3D%20New-GenericObject%20System.Collections.Generic.List%20Microsoft.ResourceManagement.WebServices.UniqueIdentifier%20%3CBR%20%2F%3E%20%24MembersToRemove%20%3D%20New-GenericObject%20System.Collections.Generic.List%20Microsoft.ResourceManagement.WebServices.UniqueIdentifier%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%20%3CBR%20%2F%3E%20%23Example%20of%20how%20to%20add%2Fremove%20a%20MIM%20Object%20by%20GUID%20%3CBR%20%2F%3E%20%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%20%3CBR%20%2F%3E%20%23%24FIMService%20%3D%20New-Object%20Microsoft.ResourceManagement.WebServices.UniqueIdentifier(%22e05d1f1b-3d5e-4014-baa6-94dee7d68c89%22)%20%3CBR%20%2F%3E%20%23%24BulitInSyncAccount%20%3D%20New-Object%20Microsoft.ResourceManagement.WebServices.UniqueIdentifier(%22fb89aefa-5ea1-47f1-8890-abe7797d6497%22)%20%3CBR%20%2F%3E%20%23%24MembersToAdd.Add(%24FIMService)%20%3CBR%20%2F%3E%20%23%24MembersToAdd.Add(%24BulitInSyncAccount)%20%3CBR%20%2F%3E%20%23%24MembersToRemove.Add(%24FIMService)%20%3CBR%20%2F%3E%20%23%24MembersToRemove.Add(%24BulitInSyncAccount)%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%24ObjectID%20%3D%20New-Object%20Microsoft.ResourceManagement.WebServices.UniqueIdentifier(%22e05d1f1b-3d5e-4014-baa6-999999999999%22)%20%3CBR%20%2F%3E%20%24MembersToRemove.Add(%24ObjectID)%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20return%20%40%7B%20%22MembersToAdd%22%20%3D%20%24MembersToAdd%3B%20%22MembersToRemove%22%20%3D%20%24MembersToRemove%20%7D%20%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-974704%22%20slang%3D%22en-US%22%3EFirst%20published%20on%20MSDN%20on%20Oct%2013%2C%202017%20Special%20Thanks%20to%20Mr.%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-974704%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3Ecustom%20workflow%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMIM%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Emim2016%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Emimwa%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Emimwal%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Eworkflows%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft
First published on MSDN on Oct 13, 2017
Special Thanks to Mr. David Hodge for putting the WAL Workflow Documentation together
Things to keep in mind
• the RemoveValues function requires a “List” to be passed to it. Adding in the GUID into the RemoveValues function didn’t seem to do it.
• An example PowerShell activity that allows you to build a list of object GUIDs to pass to the Update Resources activity.

Referencing https://social.technet.microsoft.com/Forums/en-US/63213b2d-4f31-416d-8e70-b871f37a7db8/removevaluess...
Below is how I modified it… We could probably be more elegant by add
function New-GenericObject
{
<#
.Synopsis
Create a new generic object.
.Description
Create a new generic object.
.Example
New-GenericObject -TypeName System.Collections.Generic.List  -TypeParameters Microsoft.MetadirectoryServices.CSEntryChange
#>

[CmdletBinding()]
[OutputType([object])]
param(
[parameter(Mandatory = $true)]
[string]
$TypeName,
[parameter(Mandatory = $true)]
[string[]]
$TypeParameters,
[parameter(Mandatory = $false)]
[object[]]
$ConstructorParameters
)

process
{
$genericTypeName = $typeName + '`' + $typeParameters.Count
$genericType = [Type]$genericTypeName

if (!$genericType)
{
throw "Could not find generic type $genericTypeName"
}

# Bind the type arguments to it
$typedParameters = [type[]] $TypeParameters
$closedType = $genericType.MakeGenericType($typedParameters)

if (!$closedType)
{
throw "Could not make closed type $genericType"
}

# Create the closed version of the generic type, don't forget comma prefix
,[Activator]::CreateInstance($closedType, $constructorParameters)
}
}


$MembersToAdd = New-GenericObject System.Collections.Generic.List Microsoft.ResourceManagement.WebServices.UniqueIdentifier
$MembersToRemove = New-GenericObject System.Collections.Generic.List Microsoft.ResourceManagement.WebServices.UniqueIdentifier

#########################################################
#Example of how to add/remove a MIM Object by GUID
#########################################################
#$FIMService = New-Object Microsoft.ResourceManagement.WebServices.UniqueIdentifier("e05d1f1b-3d5e-4014-baa6-94dee7d68c89")
#$BulitInSyncAccount = New-Object Microsoft.ResourceManagement.WebServices.UniqueIdentifier("fb89aefa-5ea1-47f1-8890-abe7797d6497")
#$MembersToAdd.Add($FIMService)
#$MembersToAdd.Add($BulitInSyncAccount)
#$MembersToRemove.Add($FIMService)
#$MembersToRemove.Add($BulitInSyncAccount)

$ObjectID = New-Object Microsoft.ResourceManagement.WebServices.UniqueIdentifier("e05d1f1b-3d5e-4014-baa6-999999999999")
$MembersToRemove.Add($ObjectID)

return @{ "MembersToAdd" = $MembersToAdd; "MembersToRemove" = $MembersToRemove }