none
Verify existing multivalued attribute values using powershell RRS feed

  • Question

  • I am writing a powershell script which will add value to a multivalued reference attribute ( This multivalued reference attribute name is "Admins" and is binded to person object). 

    Suppose I am adding value "Test"(Reference attribute) to multivalued reference attribute ("Admins").

    I want to check whether the value  "Test" is already present in "Admins" before adding this value to multivalued reference attribute ("Admins"). Can someone please guide me on this.

    Friday, April 4, 2014 4:24 AM

All replies

  • Hello,

    First, I invite you to use this module: https://fimpowershellmodule.codeplex.com/

    Something like this should work:

    New-FimImportObject -ObjectType Person -State Put -Anchor @{AccountName='sam'} -Changes @(
       New-FimImportChange -Operation 'Add' -AttributeName 'Admins' -AttributeValue ('Person','AccountName','test') 
    ) -ApplyNow
    

    The module will ignore update if the value is present

    Regards,


    Sylvain

    Friday, April 4, 2014 9:24 AM
  • Function AddMultivalue also ignore update if the value is present :)

    function AddMultiValue
    {
        PARAM($ImportObject, $AttributeName, $NewAttributeValue, $FullyResolved=1)
        END
        {
            $ImportChange = CreateImportChange -AttributeName $AttributeName -AttributeValue $NewAttributeValue -Operation 0
            $ImportChange.FullyResolved = $FullyResolved
            AddImportChangeToImportObject $ImportChange $ImportObject
        }
    }

    Saturday, April 5, 2014 4:48 AM