Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

PS 3 unexpected results shown on screen

Posted on 2013-12-26
2
Medium Priority
?
256 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 41

Accepted Solution

by:
footech earned 2000 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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

A brief introduction to what I consider to be the best editor for PowerShell.
Windows 10 came with  a lot of built in applications, Some organisations leave them there, some will control them using GPO's. This Article is useful for those who do not want to have any applications in their image (example:me).
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the adminiā€¦
Loops Section Overview

972 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