Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 4 years and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
if : The term 'if' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:2 char:9
+ if($_.date_time){[DateTime]$_.date_time}else{$null}
+ ~~
+ CategoryInfo : ObjectNotFound: (if:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Cannot convert null to type "System.DateTime".
At line:3 char:19
+ ... ach-Object {$_.date_time = ([DateTime]$_.date_time).ToString('yyyy-MM ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [], RuntimeException
+ FullyQualifiedErrorId : nullToObjectInvalidCast
Export-Csv : Cannot bind argument to parameter 'InputObject' because it is null.
At line:4 char:2
+ Export-Csv -NoTypeInformation -Path C:\Logs\sample_out.csv
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Export-Csv], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.ExportCsvCommand
jvierra wrote: ↑Wed Nov 20, 2019 3:41 pm
I ran your code and it works correctly. Your file has no null values.
No, it has no null values, The date_time column has values as it was exported from Office 365.
However, When I run the Powershell script directly when the files have been downloaded, it gives me the error?
And this is the result in the .CSV result output:
Last edited by ITEngineer on Wed Nov 20, 2019 4:00 pm, edited 1 time in total.
if : The term 'if' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:2 char:9
+ if($_.date_time){[DateTime]$_.date_time}else{$null}
+ ~~
+ CategoryInfo : ObjectNotFound: (if:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Cannot convert null to type "System.DateTime".
At line:3 char:19
+ ... ach-Object {$_.date_time = ([DateTime]$_.date_time).ToString('yyyy-MM ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [], RuntimeException
+ FullyQualifiedErrorId : nullToObjectInvalidCast
Export-Csv : Cannot bind argument to parameter 'InputObject' because it is null.
At line:4 char:2
+ Export-Csv -NoTypeInformation -Path C:\Logs\sample_out.csv
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Export-Csv], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.ExportCsvCommand
Of course that won't work. I just posted how to protect the test but you still have to enumerate the values.
This topic is 4 years and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.