Skip to content

Instantly share code, notes, and snippets.

@NicholasLeader
Created December 4, 2018 21:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NicholasLeader/33a5496e6feab4b13e1271dd785b4ad2 to your computer and use it in GitHub Desktop.
Save NicholasLeader/33a5496e6feab4b13e1271dd785b4ad2 to your computer and use it in GitHub Desktop.
<# Nicholas Leader 2018
Custom filter on the AV agent report
make sure file in CSV format
12.03.2018 - made the date filtering more extensible (not hard coded), grabs last 3 calender months with current month
#>
$filePath = "Example_file_path.csv"
### formats the dates to similar formats as what's contained in the spreasheet
$1monthAgo = (Get-Date).addmonths(-1) | Get-Date -Format MMMM
$2monthAgo = (Get-Date).addmonths(-2) | Get-Date -Format MMMM
$3monthAgo = (Get-Date).addmonths(-3) | Get-Date -Format MMMM
$thisYear = get-date -Format yyyy
$thisMonth = get-date -Format MMMM
(Import-Csv $filePath |
Where-Object {
($_.online -eq 'online') -or
($_.online -like "*$thisMonth*$thisyear*") -or
($_.online -like "*$1monthAgo*$thisyear*") -or
($_.online -like "*$2monthAgo*$thisyear*") -or
($_.online -like "*$3monthAgo*$thisyear*")
}).count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment