Solved

PS 3 unexpected results shown on screen

Posted on 2013-12-26
2
241 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
Microsoft Windows Server Update Service (WSUS) is free for everyone, but it lacks of some desirable features like send an e-mail to the administrator with the status of all computers on the WSUS server. This article is based on my PowerShell script …
This video discusses moving either the default database or any database to a new volume.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now