Skip to content

Add-PodePage

SYNOPSIS

Helper function to generate simple GET routes.

SYNTAX

ScriptBlock (Default)

Add-PodePage -Name <String> -ScriptBlock <ScriptBlock> [-Data <Hashtable>] [-Path <String>]
 [-Middleware <Object[]>] [-Authentication <String>] [<CommonParameters>]

File

Add-PodePage -Name <String> -FilePath <String> [-Data <Hashtable>] [-Path <String>] [-Middleware <Object[]>]
 [-Authentication <String>] [<CommonParameters>]

View

Add-PodePage -Name <String> -View <String> [-Data <Hashtable>] [-Path <String>] [-Middleware <Object[]>]
 [-Authentication <String>] [-FlashMessages] [<CommonParameters>]

DESCRIPTION

Helper function to generate simple GET routes from ScritpBlocks, Files, and Views. The output is always rendered as HTML.

EXAMPLES

EXAMPLE 1

Add-PodePage -Name Services -ScriptBlock { Get-Service }

EXAMPLE 2

Add-PodePage -Name Index -View 'index'

EXAMPLE 3

Add-PodePage -Name About -FilePath '.\views\about.pode' -Data @{ Date = [DateTime]::UtcNow }

PARAMETERS

-Authentication

The name of an Authentication method which should be used as middleware on this Route.

Type: String
Parameter Sets: (All)
Aliases: Auth

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Data

A hashtable of Data to supply to a Dynamic File/View, or to be splatted as arguments for the ScriptBlock.

Type: Hashtable
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-FilePath

A FilePath, literal or relative, to a valid HTML file.

Type: String
Parameter Sets: File
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-FlashMessages

If supplied, Views will have any flash messages supplied to them for rendering.

Type: SwitchParameter
Parameter Sets: View
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Middleware

Like normal Routes, an array of Middleware that will be applied to all generated Routes.

Type: Object[]
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Name

A unique name for the page, that will be used in the Path for the route.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Path

An optional Path for the Route, to prepend before the Name.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: /
Accept pipeline input: False
Accept wildcard characters: False

-ScriptBlock

A ScriptBlock to invoke, where any results will be converted to HTML.

Type: ScriptBlock
Parameter Sets: ScriptBlock
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-View

The name of a View to render, this can be HTML or Dynamic.

Type: String
Parameter Sets: View
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

NOTES