(WAL) – Workflow Example – Removal of a multivalued reference attribute

This post has been republished via RSS; it originally appeared at: Core Infrastructure and Security Blog articles.

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/removevaluesstringlist-not-removing-values?forum=Mimwal
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 }

REMEMBER: these articles are REPUBLISHED. Your best bet to get a reply is to follow the link at the top of the post to the ORIGINAL post! BUT you're more than welcome to start discussions here:

This site uses Akismet to reduce spam. Learn how your comment data is processed.