Repository navigation
Find XKCD
Retrieves the details of comics @ https://xkcd.com/ based on whether a specified search string appears in the title text (by default). To search for a specified string in the full text of the comic data, use the -FullSearch switch.
Find-XKCD [-Query] <String[]> [-Or <String[]>] [-And <String[]>] [-Not <String[]>] [-Year <Int32[]>]
[-Month <Int32[]>] [-Day <Int32[]>] [-FullSearch] [-Raw] [-CachePath <String>] [-SkipCacheRefresh] [-Offline]
[-ProgressAction <ActionPreference>] [<CommonParameters>]
The Find-XKCD cmdlet creates a local cache of the XKCD API comic data if one is not found to already exist. It also refreshes the local cache if it's found to be out of date. Comic searches are then performed against the local cache.
-Query accepts more than one search string. A comic matches if it contains ANY of them, or any of the -Or terms (-Query and -Or are simply two ways of building the same "match any of these" group -- -Or exists so you can add alternatives without crowding the primary -Query list). If -And is also given, a comic must additionally contain ALL of those terms to match. If -Not is also given, a comic must additionally contain NONE of those terms to match, e.g. `Find-XKCD -Query 'Spider' -Not 'Man'` returns comics with 'Spider' in the title, excluding any that also have 'Man' in it.
Each resulting comic object is tagged with a NoteProperty called 'query' -- specifically, every term that was actually part of why that comic matched: whichever -Query/-Or term(s) it matched (joined with ', ' if more than one), plus any -And terms (since all of those are required to be present, they're always part of the reason it matched too). -Not terms are never included, since they describe what must be absent, not why a comic matched.
-Year, -Month and -Day further restrict matches to comics published in the given year(s), month(s) (1-12) and/or day(s) of the month -- a comic must match one of each that's specified, alongside the text search above, e.g. `Find-XKCD -Query 'Spider' -Year 2010,2011` returns comics with 'Spider' in the title published in 2010 or 2011.
Each returned comic also has a 'date' property (a [datetime] combining day/month/year, so results can be sorted or filtered by date), and 'html_img'/'html' properties, computed from those properties, for embedding the comic in HTML output -- 'html_img' is just the <img> tag, and 'html' wraps that same tag in a link to the comic's page on xkcd.com. Use -Raw to omit these and get each comic exactly as cached (still tagged with 'query').
Use -Offline as an alternative to -SkipCacheRefresh -- it has the same effect of skipping the Update-XKCDCache step and searching the cache as it currently exists on disk, without contacting the xkcd API, but defaults to the value saved with Set-XKCDDefault -Offline rather than -SkipCacheRefresh.
Find-XKCD -Query 'Spider' | Format-Table
Returns any comics with the word 'Spider' in the title as a table.
Find-XKCD -Query 'Spider' | Get-XKCD -Open
Returns any comics with the word 'Spider' in the title and then pipes the result to Get-XKCD which opens them in the default browser.
Find-XKCD -Query 'Spider' | Get-XKCD -Show
Returns any comics with the word 'Spider' in the title and then pipes the result to Get-XKCD which shows them in the terminal, if supported.
'romance','math' | Find-XKCD | Group query
Returns any comics with the word 'romance' or 'math' in the title and then groups the results by the search term.
Find-XKCD -Query 'Spider','Robot'
Returns any comics with the word 'Spider' OR 'Robot' in the title, in a single combined result set, each tagged with whichever of the two it actually matched. Piping the terms in separately instead (`'Spider','Robot' | Find-XKCD`) returns the same comics tagged the same way, except a comic matching both terms would appear twice (once per piped query) rather than once with 'query' set to 'Spider, Robot'.
Find-XKCD -Query 'Time' -And 'Machine'
Returns any comics with both 'Time' AND 'Machine' in the title, each tagged with 'query' set to 'Time, Machine'.
Find-XKCD -Query 'Spider' -Not 'Man'
Returns comics with 'Spider' in the title, excluding any that also have 'Man' in it.
Find-XKCD -Query 'Spider' -Not 'Man','Egg'
Returns comics with 'Spider' in the title, excluding any that also have 'Man' OR 'Egg' in it.
Find-XKCD -Query 'Spider' -Raw
Returns each matching comic exactly as cached, without the 'date', 'html_img' or 'html' properties Find-XKCD normally adds (the 'query' property is still added).
Find-XKCD -Query 'Spider' -Year 2010
Returns comics with 'Spider' in the title that were published in 2010.
Find-XKCD -Query 'Spider' -Month 10 -Day 31
Returns comics with 'Spider' in the title that were published on October 31st of any year.
Find-XKCD -Query 'Spider' -Offline
Returns comics with 'Spider' in the title, searching the local cache as it currently exists on disk without contacting the xkcd API to refresh it first.
The search string(s) to find. A comic matches if it contains any of these (or any of -Or).
Type: String[]
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: FalseAdditional search string(s) to match, alongside -Query -- a comic matches if it contains any of -Query OR any of these.
Type: String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSearch string(s) that must ALL also be present for a comic to match, alongside -Query/-Or.
Type: String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSearch string(s) that must NONE be present for a comic to match, alongside -Query/-Or/-And.
Type: String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseRestricts matches to comics published in the specified year(s), alongside the text search.
Type: Int32[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseRestricts matches to comics published in the specified month(s) (1-12), alongside the text search.
Type: Int32[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseRestricts matches to comics published on the specified day(s) of the month, alongside the text search.
Type: Int32[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSearch the full text of the comic data, not just the title. Defaults to the value saved with Set-XKCDDefault -FullSearch, if any.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: (Get-XKCDDefaultValue -Name 'FullSearch' -Value $false)
Accept pipeline input: False
Accept wildcard characters: FalseReturns each matching comic object exactly as cached, without the 'date', 'html_img' or 'html' properties Find-XKCD normally adds, and without the 'XKCD.Comic'/'XKCD.Comic.Search' type names that drive its table/list formatting. The 'query' property is still added.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalsePath to where comic data is cached. By default this is within the module path, unless a default has been saved with Set-XKCDDefault -CachePath.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: (Get-XKCDDefaultValue -Name 'CachePath' -Value (Join-Path $PSScriptRoot 'XKCD.json'))
Accept pipeline input: False
Accept wildcard characters: FalseSkips the Update-XKCDCache step, searching the cache as it currently exists on disk. Useful to avoid the overhead of checking for new comics when you know the cache is already up to date. Defaults to the value saved with Set-XKCDDefault -SkipCacheRefresh, if any.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: (Get-XKCDDefaultValue -Name 'SkipCacheRefresh' -Value $false)
Accept pipeline input: False
Accept wildcard characters: FalseHas the same effect as -SkipCacheRefresh -- skips the Update-XKCDCache step and searches the cache as it currently exists on disk, without contacting the xkcd API. Defaults to the value saved with Set-XKCDDefault -Offline, if any.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: (Get-XKCDDefaultValue -Name 'Offline' -Value $false)
Accept pipeline input: False
Accept wildcard characters: False{{Fill ProgressAction Description}}
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).