Skip to main content

Exit-Script

SYNOPSISโ€‹

Exit the script, perform cleanup actions, and pass an exit code to the parent process.

SYNTAXโ€‹

Exit-Script [[-ExitCode] <Int32>] [<CommonParameters>]

DESCRIPTIONโ€‹

Always use when exiting the script to ensure cleanup actions are performed.

EXAMPLESโ€‹

EXAMPLE 1โ€‹

Exit-Script

EXAMPLE 2โ€‹

Exit-Script -ExitCode 1618

PARAMETERSโ€‹

-ExitCodeโ€‹

The exit code to be passed from the script to the parent process, e.g. SCCM

Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: 1
Default value: 0
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โ€‹

Noneโ€‹

You cannot pipe objects to this function.โ€‹

OUTPUTSโ€‹

Noneโ€‹

This function does not generate any output.โ€‹

NOTESโ€‹

https://psappdeploytoolkit.com