@lakshmana
I'll say I'm not good with excel in powershell. I always avoid dealing with excel just because there are too many area that could goes wrong in the long term.
stess
@stess
Posts made by stess
-
RE: Mail Allignment Issue
-
RE: Powershell Filter Data and Copy Data to new .csv file
@lakshmana said in Powershell Filter Data and Copy Data to new .csv file:
@stess said in Powershell Filter Data and Copy Data to new .csv file:
Hmmm.. I don't know how to post code here.$csvFile = ".\etc.csv" #dummy file. Change it to whereevery your file is at. $csvImport = Import-Csv $csvFile # Create Array for Exporting out data $csvArray = "" #this clear for testing purpose. But it works in production environment as well.. so I didn't bother to remove it. $csvArray = [System.Collections.ArrayList]@() # Entry count $lineCounter = 1 # Foreach Loop Foreach ($csvImportedItem in $csvImport){ $lineCounter++ #this let me know which line in the entry is the problem. $importedName = $csvImportedItem.Name $importedID = $csvImportedItem.ID $importedDept = $csvImportedItem.Department $importedNote = $csvImportedItem.Note if($importedNote -eq "C"){ $csvArray += $csvImportedItem "[$lineCounter] $importedName $importedID $importedDept $importedNote`n" #For outputing result. Testing purpose $csvImportedItem #For outputing result. Testing purpose } } $csvArray #For outputing result before exporting to new CSV #$csvArray | Export-Csv $NEWPATH -NoTypeInformation #destinate new path.
Name ID Department Note Caroline Bates 10035 Sales A Danny Harrison 11523 Customer Service B Armando Kelley 16423 Sales C Dorothy Colon 10245 HR B Joanna Sutton 19853 Accounting C Neat!
if there "ticket id" and "Assigned date" is there in heading means??
use " "
So$importedID = $csvImportedItem.ID
becomes
$importedID = $csvImportedItem."ticket id"
Keep the variable simple and easy to understand.
-
RE: Mail Allignment Issue
@lakshmana
Is the file XLSX or CSV? If it is CSV then the example I provided in an other thread works just fine. XLSX is a lot more trickier as you have to target the cells and what not. -
RE: Powershell Filter Data and Copy Data to new .csv file
@lakshmana
You should look more into technet articles. There are plenty of guide, tips and tricks, etc. -
RE: Powershell Filter Data and Copy Data to new .csv file
You mean send mail using whatever the data in the CSV is?
$SmtpServer = "smtp.com" $SmtpServerPort = "25 or 587" $SmtpFrom = "[email protected]" $SmtpTo = "[email protected]" $SmtpBody = "$csvArray" $SmtpSubject = "Subject" Send-MailMessage -SmtpServer $SmtpServer -Port $SmtpServerPort -From $SmtpFrom -To $SmtpTo -subject $SmtpSubject -body $SmtpBody
-
RE: Powershell Filter Data and Copy Data to new .csv file
@tim_g
Thanks! site bookmarked -
RE: Powershell Filter Data and Copy Data to new .csv file
Hmmm.. I don't know how to post code here.$csvFile = ".\etc.csv" #dummy file. Change it to whereevery your file is at. $csvImport = Import-Csv $csvFile # Create Array for Exporting out data $csvArray = "" #this clear for testing purpose. But it works in production environment as well.. so I didn't bother to remove it. $csvArray = [System.Collections.ArrayList]@() # Entry count $lineCounter = 1 # Foreach Loop Foreach ($csvImportedItem in $csvImport){ $lineCounter++ #this let me know which line in the entry is the problem. $importedName = $csvImportedItem.Name $importedID = $csvImportedItem.ID $importedDept = $csvImportedItem.Department $importedNote = $csvImportedItem.Note if($importedNote -eq "C"){ $csvArray += $csvImportedItem "[$lineCounter] $importedName $importedID $importedDept $importedNote`n" #For outputing result. Testing purpose $csvImportedItem #For outputing result. Testing purpose } } $csvArray #For outputing result before exporting to new CSV #$csvArray | Export-Csv $NEWPATH -NoTypeInformation #destinate new path.
Name ID Department Note Caroline Bates 10035 Sales A Danny Harrison 11523 Customer Service B Armando Kelley 16423 Sales C Dorothy Colon 10245 HR B Joanna Sutton 19853 Accounting C Neat!
-
RE: Powershell Filter Data and Copy Data to new .csv file
I use Foreach loop and pass the value to an Array if it meeds if() criteria. Then output the $true result back to the same CSV. I'll post the code later today.
Edit: can you post your csv data? Other wise I'll give you my data which has 4 column
Edit2: Also, for my script to works you need to manually change the if() statement manually each run. Easier to use Powershell ISE or any other powershell IDE. If you want to make it fancy then a custom textbox to return the value you are looking for is not a bad idea.
-
RE: What is it with people forcing their preferred Antivirus to other?
@scottalanmiller
I treat Windows Defender like iOS mail on iPhone. It's there.. and it works... but I'll be using MS Outlook instead of native mail app. Nothing wrong with it, but it doesn't have a lot of features other competitor offers (as you have mentioned). Still, I have no intention to disable it. -
What is it with people forcing their preferred Antivirus to other?
So I have a conversation with my colleague and the conversation somehow lead to asking what Antivirus I have installed on my computer. I said I have Malwarebytes and Windows Defender. He then proceed to say Windows Defender sucks (I'm not arguing with that since I rarely use it), and out of no where he said I should get rid of both of them and get ESET. [...] I'm like.. WTH. I would understand if he says he use ESET and how good it is, but to tell me what to do with my computer is a bit much. Beside, I've never use ESET before
What's your thought? What's your recommended (based on your experience)?
For me I am waiting for Malwarebytes' license to run out in November, and I'm going over to BitDefender.