https://github.com/marckassay/gmailfilterutil
A PowerShell module for updating Gmail filters
https://github.com/marckassay/gmailfilterutil
blacklist email-black filter gmail powershell recruiter
Last synced: 3 days ago
JSON representation
A PowerShell module for updating Gmail filters
- Host: GitHub
- URL: https://github.com/marckassay/gmailfilterutil
- Owner: marckassay
- License: mit
- Created: 2020-02-16T17:02:17.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-04-11T20:07:02.000Z (over 5 years ago)
- Last Synced: 2025-06-02T14:55:40.478Z (4 months ago)
- Topics: blacklist, email-black, filter, gmail, powershell, recruiter
- Language: PowerShell
- Homepage:
- Size: 36.1 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GmailFilterUtil
This module has been created to address the following:
- _Unable to edit large filter lists in Gmail_. It seems that Gmail doesn't allow editing large filter sets without receiving an error popup. For whatever reason why this is, I "quickly" created this module because of it.
- _Quickly update Gmail filter list_. Although, this requires additional steps to be done in Gmail, this module allows you to update your local Xml filter file to be uploaded anytime afterwards. Use the [`Add-FromList`](https://github.com/marckassay/GmailFilterUtil/blob/0.0.4/docs/Add-FromList.md) function to add new entries.
- _To have predefined Gmail filter lists_. From the plethora of recruiters contacting me, I found myself inundated to the point I was avoiding to view my inbox. Filters are a powerful tool in Gmail, so that you can avoid even seeing or needing to delete messages, which is what I needed to filter recruiter messages. Having predefined lists makes enabling this process much less painful. Submit a PR to update or add new lists](https://github.com/marckassay/GmailFilterUtil/blob/0.0.4/LICENSE)
[](https://www.powershellgallery.com/packages/GmailFilterUtil/)## Examples
In order to use this PowerShell module, you must download an initial filter from a Gmail account. It may be empty. Or it may just have a single entry. If needed, instructions can be found [here](https://support.google.com/mail/answer/6579) on managing Gmail filters.
When you have a exported filter from your Gmail account, you can update it by doing this following:
```powershell
Import-XmlFilter -Path 'C:\temp\mailFilters.xml' | `
Add-FromList -Value "*@aerotek.com" | `
Export-XmlFilter -Path 'C:\temp\mailFilters.xml'
```This example uses the [`Add-FromList`](https://github.com/marckassay/GmailFilterUtil/blob/0.0.4/docs/Add-FromList.md) function to add additional entries, as to juxtapose with [`Set-FromList`](https://github.com/marckassay/GmailFilterUtil/blob/0.0.4/docs/Set-FromList.md), which sets the value of `Value` parameter as-is, removing any existing values. This function-verb behavior aligns with PowerShell's `Add-Context` and `Set-Context` functions.
Another example, is to use a predefined list of entries. For instance, the `recruiters.us` list:
```powershell
$RecruiterEntries = Read-PredefinedFromList -ListName 'recruiters.us'
$RecruiterEntries += '*@techcorpsystems.com'
$RecruiterEntries | Export-XmlFilter -Path 'C:\temp\mailFilters.xml'
```Above, an additional entry is added to `GmailFilter` data type and exported back to `mailFilter.xml` file.
## API
#### [`Add-FromList`](https://github.com/marckassay/GmailFilterUtil/blob/0.0.4/docs/Add-FromList.md)
Adds entries to a From list.
#### [`Export-XmlFilter`](https://github.com/marckassay/GmailFilterUtil/blob/0.0.4/docs/Export-XmlFilter.md)
Exports PowerShell data back to Gmail exported filter.
#### [`Import-XmlFilter`](https://github.com/marckassay/GmailFilterUtil/blob/0.0.4/docs/Import-XmlFilter.md)
Imports into PowerShell session, a Gmail exported filter.
#### [`Read-PredefinedFromList`](https://github.com/marckassay/GmailFilterUtil/blob/0.0.4/docs/Read-PredefinedFromList.md)
{{Fill in the Synopsis}}
#### [`Set-FromList`](https://github.com/marckassay/GmailFilterUtil/blob/0.0.4/docs/Set-FromList.md)
Sets entries to a From list.