Solved

PS 3 unexpected results shown on screen

Posted on 2013-12-26
2
243 Views
Last Modified: 2013-12-29
While my program is running (uses invoke-sql, export-csv) it periodically spits this information out to the console and I do not know what is causing it???

Module                     : CommonLanguageRuntimeLibrary
Assembly                   : mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
TypeHandle                 : System.RuntimeTypeHandle
DeclaringMethod            :
BaseType                   : System.Object
UnderlyingSystemType       : System.Exception
FullName                   : System.Exception
AssemblyQualifiedName      : System.Exception, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Namespace                  : System
GUID                       : a1c0a095-df97-3441-bfc1-c9f194e494db
IsEnum                     : False
GenericParameterAttributes :
IsSecurityCritical         : False
IsSecuritySafeCritical     : False
IsSecurityTransparent      : True
IsGenericTypeDefinition    : False
IsGenericParameter         : False
GenericParameterPosition   :
IsGenericType              : False
IsConstructedGenericType   : False
ContainsGenericParameters  : False
StructLayoutAttribute      : System.Runtime.InteropServices.StructLayoutAttribute
Name                       : Exception
MemberType                 : TypeInfo
DeclaringType              :
ReflectedType              :
MetadataToken              : 33554437
GenericTypeParameters      : {}
DeclaredConstructors       : {Void .ctor(), Void .ctor(System.String), Void .ctor(System.String, System.Exception), Void
                             .ctor(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)...}
DeclaredEvents             : {System.EventHandler`1[System.Runtime.Serialization.SafeSerializationEventArgs] SerializeObjectState}
DeclaredFields             : {_className, _exceptionMethod, _exceptionMethodString, _message...}
DeclaredMembers            : {System.String get_Message(), Void
                             add_SerializeObjectState(System.EventHandler`1[System.Runtime.Serialization.SafeSerializationEventArgs]), Void
                             remove_SerializeObjectState(System.EventHandler`1[System.Runtime.Serialization.SafeSerializationEventArgs]), System.Collections.IDictionary
                             get_Data()...}
DeclaredMethods            : {System.String get_Message(), Void
                             add_SerializeObjectState(System.EventHandler`1[System.Runtime.Serialization.SafeSerializationEventArgs]), Void
                             remove_SerializeObjectState(System.EventHandler`1[System.Runtime.Serialization.SafeSerializationEventArgs]), System.Collections.IDictionary
                             get_Data()...}
DeclaredNestedTypes        : {System.Exception+__RestrictedErrorObject, System.Exception+ExceptionMessageKind}
DeclaredProperties         : {System.String Message, System.Collections.IDictionary Data, System.Exception InnerException, System.Reflection.MethodBase TargetSite...}
ImplementedInterfaces      : {System.Runtime.Serialization.ISerializable, System.Runtime.InteropServices._Exception}
TypeInitializer            : Void .cctor()
IsNested                   : False
Attributes                 : AutoLayout, AnsiClass, Class, Public, Serializable, BeforeFieldInit
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                   : False
IsSpecialName              : False
IsImport                   : False
IsSerializable             : True
IsAnsiClass                : True
IsUnicodeClass             : False
IsAutoClass                : False
IsArray                    : False
IsByRef                    : False
IsPointer                  : False
IsPrimitive                : False
IsCOMObject                : False
HasElementType             : False
IsContextful               : False
IsMarshalByRef             : False
GenericTypeArguments       : {}
CustomAttributes           : {[System.SerializableAttribute()],
                             [System.Runtime.InteropServices.ClassInterfaceAttribute((System.Runtime.InteropServices.ClassInterfaceType)0)],
                             [System.Runtime.InteropServices.ComDefaultInterfaceAttribute(typeof(System.Runtime.InteropServices._Exception))],
                             [System.Runtime.InteropServices.ComVisibleAttribute((Boolean)True)]...}
0
Comment
Question by:johnj_01201
2 Comments
 
LVL 1

Author Comment

by:johnj_01201
ID: 39742482
This appears to have been caused by a line that reads:
$CSVRecord
which is inside a foreach($CSVRecord in $CSV) loop, and $CSV is the result of an invoke-sql statement.

It seems that sometimes the $CSVRecord is NULL and displays the above information, however I thought that was impossible seeing how I was in a foreach loop...
0
 
LVL 39

Accepted Solution

by:
footech earned 500 total points
ID: 39745238
however I thought that was impossible seeing how I was in a foreach loop
Not at all.  If $CSV is an array which includes elements that are null, then $CSVRecord will sometimes be null.
Best way around this is to filter or perform some validation of the results before they are stored in $CSV.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Utilizing an array to gracefully append to a list of EmailAddresses
Synchronize a new Active Directory domain with an existing Office 365 tenant
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question