functionRegister-DbaMaintenanceTask{<#
.SYNOPSIS
Allows scheduling maintenance tasks, that are perfomed in the background.

.DESCRIPTION
Allows scheduling maintenance tasks, that are perfomed in the background.

All scriptblocks scheduled like this will be performed on a separate runspace and have access to all internal dbatools commands.
None of the scriptblocks will affect the main session (so you cannot manipulate variables, etc.)

.PARAMETER Name
The name of the task.
Must be unique, otherwise it will update the existing task.

.PARAMETER ScriptBlock
The task/scriptblock that should be performed as part of the maintenance.
It will have all of dbatools including internal commands available.

.PARAMETER Once
Whether the interval should be performed only once.

.PARAMETER Interval
The interval at which the task should be repeated.

.PARAMETER Delay
How far after the initial registration should the maintenance script wait before processing this.
This can be used to delay background stuff that should not content with items that would be good to have as part of the module import.
Some library specific items can be moved to maintenance if their processing would take too much time on original import, even if it is desirable to have them available as soon as possible.

.PARAMETER Priority
How important is this task?
If multiple tasks are due at the same maintenance cycle, the more critical one will be processed first.

.PARAMETER EnableException
By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.