Looking for a PowerShelly way to set multiple values simultaneously on a multivalue ARS virtual attribute

I've eliminated the wrong ways to do this ... now seeking advice on using set-qadcomputer  to apply a row/array of values to an ARS virtual attribute

Tried this:

$strVaValue = "'value1' ; 'value2' ; 'value3'"
$arSession = connect-qadservice -service <host> -proxy

Set-QADComputer -Connection $ARSession -Identity $objComputer.DN -ObjectAttributes @{edsvaVirtualAttributeName=@{Append=@($strVaValue)}}

I ended up with one entry in the multivalue attribute with the value "'value1' ; 'value2' ; 'value3'"
not usefule, and each of the entries should be an element

  • You are most of the way there...

    $strVaValue = @('value1' , 'value2' , 'value3')


    $arSession = connect-qadservice -service <host> -proxy

    foreach ($strVaValueItem in $strVaValue)

    {

    Set-QADComputer -Connection $ARSession -Identity $objComputer.DN -ObjectAttributes @{edsvaVirtualAttributeName=@{Append=@($strVaValueItem)}}

    } # End of looping through $strVaValue list

  • Thanks for that JohnnyQ … that saved me from a self inflicted wound today ; )

    from your example - the $strVaValue is set as an array - DOH! … it's not a string anymore.

    I totally forgot about that collection of values - being an array inside the va.

    so,  set my string value as an array and used the whole array inside objectAttributes .. and it worked! - in one pass without iteration … saving room in my change history database to boot.

    Remembered - for the next time I fat finger my command line.

    $myArray = @('value1','value2','value3')
    Set-QADComputer -Connection $ARSession -Identity $objComputer.DN -objectAttributes @{edsvaVirtualAttribueName=@{Update=@($($myArray))}}

    I used update here rather than append, because I wanted to erase the junk I had previously sent.

  • I didn't want to change your code too much but hey, regardless, I'm glad it worked out!

  • last question on the topic … Before I break something else on my testing box … is it your considered opinion that the same approach would work with this method - over the set-QADComputer commandlet way? 

    $ADObj = [ADSI]("EDMS://" + $objComputer.properties.dstinguishedname)

    $ADObj.putex(2,'edsvaVirtualAttributeName',@($($myarray)))

    $ADObj.setinfo()

  • If you want to set using the array, your 2 should be a 3.

  • In this instance - I definitely needed the array - as my booboo replaced all existing values for a few hundred objects  with just the one add-on value.
    oops.  I'd never considered this before - but RMAD doesn't include the ARS virtual attributes assigned to objects in AD ... What an enhancement that would be!
    I was able to pull the prior value from change history - 'before' the after ... I wish the PS> commands would expose that too. Can I hear .. another enhancement?

    Much appreciated Johnny Q! - thanks for sharing your knowledge.