New-PSUEndpoint
SYNOPSIS
Creates a new REST API endpoint.
SYNTAX
Endpoint
New-PSUEndpoint [-Method <String[]>] -Url <String> [-Description <String>] -Endpoint <ScriptBlock>
[-Path <String>] [-Authentication] [-Role <String[]>] [-RegEx] [-Tag <Tag[]>] [-Timeout <Int32>]
[-Environment <String>] [-PersistentLog] [-Documentation <String>] [-Module <String>] [-Command <String>]
[-Credential <String>] [-ComputerGroup <String[]>] [-AvailableInBranch <String[]>] [-Disabled]
[-ExecutionRole <String[]>] [-ComputerName <String>] [-AppToken <String>] [-UseDefaultCredentials]
[-Integrated] [-TrustCertificate] [-Cookies] [<CommonParameters>]Path
New-PSUEndpoint [-Method <String[]>] -Url <String> [-Description <String>] -Path <String> [-Authentication]
[-Role <String[]>] [-RegEx] [-Tag <Tag[]>] [-Timeout <Int32>] [-Environment <String>] [-PersistentLog]
[-Documentation <String>] [-Module <String>] [-Command <String>] [-Credential <String>]
[-ComputerGroup <String[]>] [-AvailableInBranch <String[]>] [-Disabled] [-ExecutionRole <String[]>]
[-ComputerName <String>] [-AppToken <String>] [-UseDefaultCredentials] [-Integrated] [-TrustCertificate]
[-Cookies] [<CommonParameters>]Module
DESCRIPTION
Creates a new REST API endpoint.
This cmdlet is a configuration cmdlet. You can use it with the PowerShell Universal configuration system as well as the PowerShell Universal Management API. Endpoints are stored within the ./universal/endpoints.ps1 file.
EXAMPLES
Example 1
Creates a REST API endpoint that returns "Hello" when the user calls it via the GET HTTP method.
Example 2
Creates a REST API that users variables. Variables allow users to pass data to the REST API. They will appear as PowerShell variables within the endpoint script block.
Example 3
Creates a REST API that requires authentication and authorization. Only users with a valid AppToken can access this endpoint and only users that hold the Administrators role.
Example 4
Creates a REST API using the PowerShell Universal Management API. When calling the management API, you will need to define the computer name and the app token to successfully call the API.
PARAMETERS
-AppToken
The AppToken that is used for calling the PowerShell Universal Management API. You can also call Connect-PSUServer before calling this cmdlet to set the AppToken for the entire session.
-Authentication
Specifies whether this endpoint requires authentication. Authentication requires an API license.
-ComputerName
Specifies the computer name or URL that should be called when accessing the PowerShell Universal Management API. You can also use Connect-PSUServer before calling this cmdlet to set the computer name for the entire session.
-Endpoint
The contents of the endpoint. This is the PowerShell script that will be called when the REST API is executed.
-Method
The HTTP methods that are required for calling this endpoint.
-RegEx
Specifies whether to process the URL provided as a RegEx string rather than a literal URL.
-Role
Specifies the role that is required for accessing this endpoint. The -Authentication parameter should also be specified when using the -Role parameter. Roles require an API license.
-Url
The URL of the endpoint. This URL can be a RegEx expression if you specify the -RegEx switch parameter. This URL can also contain variables using the colon (:) prefix.
-Description
A description for the endpoint to display in the console.
-UseDefaultCredentials
Use default credentials when connecting to the management API
-Integrated
Executes the command internally rather than using the Management API. Only works when running script from within PowerShell Universal.
-Tag
Tags for this endpoint.
-Timeout
The timeout in seconds for this API endpoint. 0 or not defined means no timeout.
-Path
The path to a PS1 file containing the content of this endpoint.
-Environment
The environment to run this endpoint within.
-PersistentLog
Whether to store the log for this endpoint in the database.
-Documentation
The documentation definition to associate this end with.
-Command
The command that defines this endpoint content.
-Module
The module that contains the command that defines this endpoint content.
-ComputerGroup
The computer group to run this endpoint on.
-AvailableInBranch
When specified, the endpoint will only be available in the specified branches.
-Credential
Credentials to login to the PowerShell Universal Management API.
-TrustCertificate
Whether the cmdlet should ignore certificate issues.
-Disabled
Disables the endpoint. The endpoint will not be available until it is enabled.
-Cookies
Reuses and persists authentication cookies for the current PowerShell session.
-ExecutionRole
Specifies one or more roles that can execute the resource.
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -Verbose, -WarningAction, -WarningVariable, and -ProgressAction. For more information, see about_CommonParameters.
INPUTS
None
OUTPUTS
System.Object
NOTES
RELATED LINKS
PERMISSIONS
The access token requires apis.endpoints/create to run this cmdlet remotely.
Last updated
Was this helpful?