Search found 198 matches

by ITEngineer
Sun Nov 24, 2019 9:41 pm
Forum: PowerShell
Topic: Importing .CSV showing many NULL character?
Replies: 3
Views: 2572

Importing .CSV showing many NULL character?

People, I have just downloaded the .CSV from Office 365 with the content of Message Transport logs. However, the Notepad++ showing it as NULL typed content as per below screenshot: https://i.imgur.com/VUAEVvV.png How to correctly import this file so I can use it against the Powershell script correct...
by ITEngineer
Wed Nov 20, 2019 5:03 pm
Forum: PowerShell
Topic: Cannot convert null to type "System.DateTime".
Replies: 8
Views: 3740

Re: Cannot convert null to type "System.DateTime".

jvierra wrote:
Wed Nov 20, 2019 4:54 pm
I get no errors and cannot guess as to your issue. If the file is being downloaded then you may have issues.
No, it is already downloaded perfectly and then I have clicked the Unblock button to make sure Excel have access.
by ITEngineer
Wed Nov 20, 2019 4:53 pm
Forum: PowerShell
Topic: Cannot convert null to type "System.DateTime".
Replies: 8
Views: 3740

Re: Cannot convert null to type "System.DateTime".

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 ...
by ITEngineer
Wed Nov 20, 2019 4:51 pm
Forum: PowerShell
Topic: Cannot convert null to type "System.DateTime".
Replies: 8
Views: 3740

Re: Cannot convert null to type "System.DateTime".

Just do this: if($_.date_time){[DateTime]$_.date_time}else{$null} Strangely it does not work? Import-Csv -Path C:\Logs\input.csv | if($_.date_time){[DateTime]$_.date_time}else{$null} ForEach-Object {$_.date_time = ([DateTime]$_.date_time).ToString('yyyy-MM-dd HH:mm:ss tt'); $_} | Export-Csv -NoType...
by ITEngineer
Wed Nov 20, 2019 4:29 pm
Forum: PowerShell
Topic: Cannot convert null to type "System.DateTime".
Replies: 8
Views: 3740

Cannot convert null to type "System.DateTime".

Folks, I need some assistance in how to convert one column in a .CSV file date_time into the yyyy-MM-dd HH:mm:ss tt format ,so I can sort it on the Excel. this is the script: Import-Csv -Path C:\Logs\input.csv | ForEach-Object {$_.date_time = ([DateTime]$_.date_time).ToString('yyyy-MM-dd HH:mm:ss tt...
by ITEngineer
Thu Nov 07, 2019 5:16 am
Forum: PowerShell
Topic: Get-WinEvent filtering considerations?
Replies: 6
Views: 3125

Re: Get-WinEvent filtering considerations?

Yes, that does make sense.

However, since Xpath and XML is rather hard to build or type / compile, is there any helper or way to create it ?
by ITEngineer
Wed Nov 06, 2019 11:11 pm
Forum: PowerShell
Topic: Get-WinEvent filtering considerations?
Replies: 6
Views: 3125

Re: Get-WinEvent filtering considerations?

Cool, thanks, Mr. Vierra.

So in this case, I assume there is no speed difference when using any of those three when Filtering the Event types, not the data?
by ITEngineer
Wed Nov 06, 2019 10:52 pm
Forum: PowerShell
Topic: Get-WinEvent filtering considerations?
Replies: 6
Views: 3125

Get-WinEvent filtering considerations?

Hi, I'd like to know when to use which filtering methods for the Get-WinEvent cmdlet? I can see from https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.diagnostics/get-winevent?view=powershell-6 there are three methods: -FilterHashtable -FilterXPath -FilterXml Your assistance an...
by ITEngineer
Wed Nov 06, 2019 3:19 am
Forum: PowerShell
Topic: Powershell to convert Excel to PDF not working?
Replies: 8
Views: 3856

Re: Powershell to convert Excel to PDF not working?

Still the same issue? PS C:\WINDOWS\system32> C:\Logs\Convert-ToPDF.PS1 1:Processing C:\Logs\MultipleMembers.xls You cannot call a method on a null-valued expression. 2:Processing C:\Logs\OnPremise.xlsx You cannot call a method on a null-valued expression. Exception calling "ReleaseComObject" with "...
by ITEngineer
Tue Nov 05, 2019 11:31 pm
Forum: PowerShell
Topic: Powershell to convert Excel to PDF not working?
Replies: 8
Views: 3856

Re: Powershell to convert Excel to PDF not working?

$xl = New-Object -ComObject Excel.Application $counter = 0 Get-ChildItem -path C:\Logs\* -include *.xls,*.xlsx -recurse | ForEach-Object{ $counter++ $pdfname = $_.FullName -replace 'xlsx$|xls$','pdf' $f = Get-Item $pdfname -ErrorAction SilentlyContinue if($f -and $f.Length -gt 3kb){ Write-Host "ski...