For the complete documentation index, see llms.txt. This page is also available as Markdown.

New-PSULoggingTarget

Creates a new logging target in PowerShell Universal.

SYNOPSIS

Creates a new logging target in PowerShell Universal.

SYNTAX

New-PSULoggingTarget -Type <String> [-Properties <Hashtable>] [-Level <String>] [-Feature <String>]
 [-Resource <String>] [-Scope <String>] [-ScriptBlock <ScriptBlock>] [-ComputerName <String>]
 [-AppToken <String>] [-Credential <PSCredential>] [-UseDefaultCredentials] [-Integrated] [-TrustCertificate]
 [-Cookies] [<CommonParameters>]

DESCRIPTION

Creates a new logging target in PowerShell Universal.

EXAMPLES

Example 1

New-PSULoggingTarget -Type 'PowerShell' -Level 'Information' -Scope User -Feature API -ScriptBlock {
    param($LogEvent, $Message) 
    
    $Message | Out-File C:\logs\log.txt
}

A custom logging target that writes to a file.

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.

-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.

-Feature

The feature that this logging target will receive messages from.

-Integrated

Executes the command internally rather than using the Management API. Only works when running script from within PowerShell Universal.

-Level

The base log level this logging target will receive messages from.

-Properties

The properties that should be passed to the logging target.

-Resource

The resource that this logging target will receive messages from.

-Scope

The scope that this logging target will receive messages from.

-ScriptBlock

The script block that will be executed when a log message is received when using the PowerShell logging target.

-Type

The type of logging target to create.

-UseDefaultCredentials

Uses the credentials of the current user.

-Credential

Credentials to login to the PowerShell Universal Management API.

-TrustCertificate

Whether the cmdlet should ignore certificate issues.

-Cookies

Reuses and persists authentication cookies for the current PowerShell session.

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

PowerShellUniversal.LoggingTarget

NOTES

Last updated

Was this helpful?