I’m just going to cut to the chase on this one..
copilot "How to filter ID column not being empty and if it isn't empty it starts with a number and the other column named sideindicator having a r in it using powershell and importexcel and both criteria must be true?"
╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗
║Q: How to filter ID column not being empty and if it isn't empty it starts with a number and the other column named sideindicator having a r in it using powershell and importexcel and both criteria must be true? ║
║═════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════║
║1: $data = Import-Excel -Path "C:\Path\To\File.xlsx" ║
║2: $data | Where-Object {$_.ID -and $_.ID -match '^\d' -and $_.SideIndicator -eq 'r'} ║
╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝
How about that? Nice little RegEx in there too! Yes this does work, as I used it this morning for a real life solution.
Download Doug Finke’s PowerShellAI module, get your OpenAI API key, and start having some fun! And if for some reason you still haven’t downloaded his ImportExcel module get that too! And want to hear a little more about Doug, check him out on the PowerShell Podcast and find out how ImportExcel is created.
That’s enough for today, I don’t want to take away your time from playing with this!
PowerShell Gallery:
PowerShellAI
GitHub:
PowerShellAI
Leave a Reply