May 25 2020 06:51 AM
I have location where a software saves an Excel File for me. ( I control the location, time and other things)
I have a powershell script already that emails this file to my Outlook Groups.
I need to see if i can add another code before emailing which compares/analysis the size of the file , lets say the file is 500 BYtes ( no data in the file) , then do not email or the next code doesn't execute/
if it is more than 500 bytes, then yes, execute the next line of code.
May 26 2020 12:36 AM
@ankit shukla You can do something like this:
Get-ChildItem | where { (-NOT $_.PSIsContainer) -and ($_.Length -gt 0.5KB) }
Good luck
Grtz, Manfred de Laat
Jun 28 2020 03:34 PM - edited Jun 28 2020 03:51 PM
something like this
if ((dir c:\temp\yourExcelfile.xlsx ).Length -gt 500) {"do hard work to sen the e-mail"}
#or
(dir *.xlsx -file)|
?{ $_.Length -gt 500}|
%{"Is greater do hard work to send the e-mail with file $($_.fullname)"}