PoshCode Archive  Check-in [6db232973f]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Gmail can now import and export filters as XML. This script will read in an XML file generated by Gmail (the Path parameter), and create from it a flat PSObject with Id, Updated, Name and Value fields. Since it is flat, you must use the Id field to correlate the filter criteria and actions. As far as I can tell, the first item in a filter is the criteria, and any subsequent ones describe the action to take. More info about filter import/export can be found here: http://gmailblog.blogspot.com/2009/03/new-in-labs-filter-importexport.html
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:6db232973f03454db3ff24d9b49a2e49101a5973535b117b8800a0a5cb3f53be
User & Date: unknown 2018-06-10 14:27:26
Context
2018-06-10
14:27
This script customizes the welcome screen which PowerGUI admin console displays on start-up or when a folder is selected in the left-hand tree. check-in: 31d8801812 user: Dmitry Sotnikov tags: trunk
14:27
Gmail can now import and export filters as XML. This script will read in an XML file generated by Gmail (the Path parameter), and create from it a flat PSObject with Id, Updated, Name and Value fields. Since it is flat, you must use the Id field to correlate the filter criteria and actions. As far as I can tell, the first item in a filter is the criteria, and any subsequent ones describe the action to take. More info about filter import/export can be found here: http://gmailblog.blogspot.com/2009/03/new-in-labs-filter-importexport.html check-in: 6db232973f user: unknown tags: trunk
14:27
Simple Function to get powershell version check-in: c98cda048b user: Powershell Jedi tags: trunk
Changes

Added Import-GmailFilterXml.ps1.

































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# encoding: ascii
# api: powershell
# title: Import-GmailFilterXml
# description: Gmail can now import and export filters as XML. This script will read in an XML file generated by Gmail (the Path parameter), and create from it a flat PSObject with Id, Updated, Name and Value fields.  Since it is flat, you must use the Id field to correlate the filter criteria and actions.  As far as I can tell, the first item in a filter is the criteria, and any subsequent ones describe the action to take.  More info about filter import/export can be found here: http://gmailblog.blogspot.com/2009/03/new-in-labs-filter-importexport.html
# version: 0.1
# license: CC0
# x-poshcode-id: 960
# x-archived: 2009-03-29T05:34:20
#
# P.S. Pipe this to Out-GridView (PowerShell v2 only) for a nice display.
# TODO:  – script the actual export of filters from gmail, removing need for working with the file at all – display in a treeview to better visualize the multiple items in each entry.
#
param (
	$Path
)
[xml]$flt = Get-Content -Path $Path
$title = $flt.feed.title
$author = $flt.feed.author.name
$output = @()
foreach ( $entry in $flt.feed.entry ) {
	foreach ( $property in $entry.property ) {
		foreach ($item in $property) {
			$process = "" | select Id, Updated, Name, Value
			$process.Id = $entry.Id
			$process.Updated = [datetime]$entry.Updated
			$process.Name = $item.Name
			$process.Value = $item.Value
			$output += $process
		}
	}
}
$output