Я получаю странное поведение при передаче объекта массива из главного сценария в код кода RunSpace. Я пытаюсь получить значения с помощью инструкции Where-Object
в коде кода RunSpace. Но производит ошибку, относящуюся к нулевому методу.Hash Array в RunSpace
Если я выполняю тот же оператор Where-Object
на массиве перед передачей в пробел, то он работает?
Например, если я выполнить следующие действия на массиве до его передается пространство выполнения его прекрасно работает:
$ARRAY | Where-Object {$_.object -eq $Variable}).PropertyofwhatIWant.ToString()
Если я прохожу этот массив в пространство выполнения и выполнять то же самое, что терпит неудачу с:
You cannot call a method on a null-valued expression. At line:25 char:13 + $strSourceGivenName = ($arr_Src_Users1 | Where-Object {$_.objectsid ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull
Я сравнивал оба объекта массива и обладает теми же свойствами? При проверке Get-Member
нет разницы в значениях ARRAY и ARRAY1? Что происходит?
Module : CommonLanguageRuntimeLibrary Assembly : mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 TypeHandle : System.RuntimeTypeHandle DeclaringMethod : BaseType : System.Array UnderlyingSystemType : System.Object[] FullName : System.Object[] AssemblyQualifiedName : System.Object[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Namespace : System GUID : 00000000-0000-0000-0000-000000000000 IsEnum : False GenericParameterAttributes : IsSecurityCritical : False IsSecuritySafeCritical : False IsSecurityTransparent : True IsGenericTypeDefinition : False IsGenericParameter : False GenericParameterPosition : IsGenericType : False IsConstructedGenericType : False ContainsGenericParameters : False StructLayoutAttribute : Name : Object[] MemberType : TypeInfo DeclaringType : ReflectedType : MetadataToken : 33554432 GenericTypeParameters : {} DeclaredConstructors : {Void .ctor(Int32)} DeclaredEvents : {} DeclaredFields : {} DeclaredMembers : {Void Set(Int32, System.Object), System.Object& Address(Int32), System.Object Get(Int32), Void .ctor(Int32)} DeclaredMethods : {Void Set(Int32, System.Object), System.Object& Address(Int32), System.Object Get(Int32)} DeclaredNestedTypes : {} DeclaredProperties : {} ImplementedInterfaces : {System.ICloneable, System.Collections.IList, System.Collections.ICollection, System.Collections.IEnumerable...} TypeInitializer : IsNested : False Attributes : AutoLayout, AnsiClass, Class, Public, Sealed, Serializable IsVisible : True IsNotPublic : False IsPublic : True IsNestedPublic : False IsNestedPrivate : False IsNestedFamily : False IsNestedAssembly : False IsNestedFamANDAssem : False IsNestedFamORAssem : False IsAutoLayout : True IsLayoutSequential : False IsExplicitLayout : False IsClass : True IsInterface : False IsValueType : False IsAbstract : False IsSealed : True IsSpecialName : False IsImport : False IsSerializable : True IsAnsiClass : True IsUnicodeClass : False IsAutoClass : False IsArray : True IsByRef : False IsPointer : False IsPrimitive : False IsCOMObject : False HasElementType : True IsContextful : False IsMarshalByRef : False GenericTypeArguments : {} CustomAttributes : {[System.SerializableAttribute()]}
Как вы передаете массив в пространство? –