jvierra wrote: ↑Mon Apr 30, 2018 3:07 am
The old ConvertTo-DataTable may have some issues. You need to use the newer version.
Thanks jvierra, I will update to the latest version ASAP.
This is an interesting one, and like you say, may be resolved in the latest version but in case any one else is interested... I shall describe what I found:
It seems that there is an issue only with null values when the datatype is set to 'datetime'.
When I queried all the columns, I noticed that all columns were already set to 'AllowDBNull = True', so I thought it strange why I was receiving the errors for the cells that contain a null value for 'DisconnectTime'!
I then started to look at the 'DataType' for each column. When I set the 'datatype' for the DisconnectTime column from 'datetime' to 'string' I no longer receive the errors.
I am not sure why?
This is the info I queried for the columns:
column = UserName, allowdbnull = True, datatype = string
column = SessionState, allowdbnull = True, datatype = Microsoft.RemoteDesktopServices.Management.SESSION_STATE
column = CreateTime, allowdbnull = True, datatype = datetime
column = DisconnectTime, allowdbnull = True, datatype = datetime
column = IdleTime, allowdbnull = True, datatype = uint32
column = CollectionName, allowdbnull = True, datatype = string
column = HostServer, allowdbnull = True, datatype = string
I changed the datatype with the following:
Code: Select all
$Table.Columns['DisconnectTime'].DataType = 'string'