Me gustaría utilizar un HashSet en un script de powershell. Creo que he descubierto la manera de crear instancias de objetos de colección genéricos haciendo:¿Puedo usar System.Core.dll/System.Collections.Generic.HashSet en powershell?
[type] $strType = "string"
$listClass = [System.Collections.Generic.List``1]
$listObject = $base.MakeGenericType(@($t))
$myList = New-Object $setObject
Esto funciona bien para las listas y diccionarios, pero cuando intento crear un HashSet me sale:
Unable to find type [System.Collections.Generic.HashSet`1]: make sure that the assembly containing this type is loaded.
Así Parece que ahora necesito cargar System.Core.dll pero parece que no puedo obtener PowerShell para cargar ese ensamblaje. Por ejemplo llamando [System.Reflection.Assembly] :: LoadWithPartialName ("System.Core") causa esta excepción:
"LoadWithPartialName" with "1" argument(s): "Could not load file or assembly 'System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified."
Cualquier punteros?
que están en PowerShell v1 o v2? – x0n
Estoy en Win2k8 R2 y get-host dice la versión 2.0 – nick
Posible duplicado: vea la respuesta a http://stackoverflow.com/questions/184476/powershell-generic-collections – zdan