Когда я читаю свойство «Сертификаты» пользователя AD, например, так:
$allProfileRawCerts = (Get-ADUser -Server example.com -Filter {EmailAddress -eq $Mail} -Property Certificates).Certificates
В результате получается тип данных ADPropertyValueCollection.
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True False ADPropertyValueCollection System.Collections.CollectionBase
Однако, если я хочу использовать это дляустановить свойство, очевидно другой тип данных ожидается:
Get-ADUser -Server example.com -Filter {EmailAddress -eq $Mail} | Set-ADUser -Certificates $array
Set-ADUser : Cannot convert 'Microsoft.ActiveDirectory.Management.ADPropertyValueCollection' to the type 'System.Collections.Hashtable' required by parameter 'Certificates'. Specified method is not
supported.
At line:1 char:100
+ ... 68 -Filter {EmailAddress -eq $Mail} | Set-ADUser -Certificates $allProfileRawCerts
+ ~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgument,Microsoft.ActiveDirectory.Management.Commands.SetADUser
Как преобразовать его, чтобы я мог его использовать?