Repository navigation
Test XKCD
Checks whether any new comics have been published since the last time Test-XKCD was run.
Test-XKCD [-Quiet] [-Detailed] [-StatePath <String>] [-Offline] [-CachePath <String>]
[-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
Test-XKCD [-Number] <Int32> [-Offline] [-CachePath <String>] [-ProgressAction <ActionPreference>] [-WhatIf]
[-Confirm] [<CommonParameters>]
Test-XKCD [-AddToProfile] [-Offline] [-CachePath <String>] [-ProgressAction <ActionPreference>] [-WhatIf]
[-Confirm] [<CommonParameters>]
Test-XKCD [-RemoveFromProfile] [-Offline] [-CachePath <String>] [-ProgressAction <ActionPreference>] [-WhatIf]
[-Confirm] [<CommonParameters>]
The Test-XKCD cmdlet compares the latest comic number available from the XKCD API against a local record of the most recently viewed comic (updated by Show-XKCD and Get-XKCD -Show), and reports whether any new comics are available. Test-XKCD only reads this record -- it never updates it.
By default it writes a friendly message to the console stating how many new comics are available and the publish date of the latest one, if that date can be determined. Use -Quiet to suppress this message and instead return a boolean. Use -Detailed to return a PSCustomObject describing how many new comics are available, alongside the last viewed and latest comic numbers.
Use -Number to instead test whether a specific numbered comic exists, returning $true or $false.
Use -AddToProfile to add `if (Test-XKCD -Quiet) { Test-XKCD }` to your PowerShell profile (creating it, and its containing directory, if either doesn't already exist), so new comics are reported automatically whenever you open a new session. Does nothing if that line is already present. Use -RemoveFromProfile to remove it again -- does nothing if the profile doesn't exist or doesn't contain that line.
Use -Offline to check the local cache (created/refreshed by Update-XKCDCache) for the latest comic, or (with -Number) whether a specific comic exists in it, instead of querying the xkcd API. Defaults to the value saved with Set-XKCDDefault -Offline, if any.
Test-XKCD
Writes a friendly message to the console stating how many new comics are available (if any) and the publish date of the latest one, where determinable.
Test-XKCD -Quiet
Returns $true if new comics are available since the last check, otherwise $false, without writing a message to the console.
Test-XKCD -Detailed
Returns a PSCustomObject detailing whether new comics are available, how many, and the last viewed vs latest comic numbers.
Test-XKCD -Number 999999
Returns $true if comic #999999 exists, otherwise $false.
Test-XKCD -Offline
Writes a friendly message to the console stating how many new comics are available, determined from the local cache rather than the xkcd API.
Test-XKCD -Number 999999 -Offline
Returns $true if comic #999999 exists in the local cache, otherwise $false, without contacting the xkcd API.
if (Test-XKCD -Quiet) { Test-XKCD }
If new comics are available, this will write a friendly message to the console stating how many new comics are available (if any) and the publish date of the latest one, where determinable.
Add this to your PowerShell profile.ps1 to have it run automatically when you open a new session and prompt you only when new comics are available.
Test-XKCD -AddToProfile
Adds `if (Test-XKCD -Quiet) { Test-XKCD }` to your PowerShell profile, creating the profile file (and its containing directory) if it doesn't already exist. Does nothing if that line is already present.
Test-XKCD -RemoveFromProfile
Removes `if (Test-XKCD -Quiet) { Test-XKCD }` from your PowerShell profile, if it's there. Does nothing if the profile doesn't exist or doesn't contain that line.
Tests whether the specified comic number exists, returning $true or $false. When used, no other parameters are considered.
Type: Int32
Parameter Sets: Number
Aliases: Num
Required: True
Position: 1
Default value: 0
Accept pipeline input: False
Accept wildcard characters: FalseAdds `if (Test-XKCD -Quiet) { Test-XKCD }` to your PowerShell profile (creating it, and its containing directory, if either doesn't already exist), so new comics are reported automatically whenever you open a new session. Does nothing if that line is already present.
Type: SwitchParameter
Parameter Sets: AddToProfile
Aliases:
Required: True
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseRemoves `if (Test-XKCD -Quiet) { Test-XKCD }` (and, if present immediately above it, the comment -AddToProfile adds) from your PowerShell profile. Does nothing if the profile doesn't exist or doesn't contain that line.
Type: SwitchParameter
Parameter Sets: RemoveFromProfile
Aliases:
Required: True
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseSuppresses the friendly console message and instead returns a boolean.
Type: SwitchParameter
Parameter Sets: Default
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseReturns a detailed PSCustomObject describing how many new comics are available, instead of a boolean or console message.
Type: SwitchParameter
Parameter Sets: Default
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalsePath to the file that tracks the number of the most recently viewed comic (written by Show-XKCD and Get-XKCD -Show). By default this is in the user's per-user data directory (~/.xkcd), unless a default has been saved with Set-XKCDDefault -StatePath.
Type: String
Parameter Sets: Default
Aliases:
Required: False
Position: Named
Default value: (Get-XKCDDefaultValue -Name 'StatePath' -Value (Get-XKCDUserDataPath -FileName 'XKCD.state.json' -LegacyDirectory $PSScriptRoot))
Accept pipeline input: False
Accept wildcard characters: FalseChecks the local cache for the latest comic, or (with -Number) whether a specific comic exists in it, instead of querying 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: FalseUse with -Offline to specify 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: FalseShows what would happen if the cmdlet runs. The cmdlet is not run.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalsePrompts you for confirmation before running the cmdlet.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
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).