Created
December 4, 2018 21:25
-
-
Save NicholasLeader/33a5496e6feab4b13e1271dd785b4ad2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# 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