PowerShell terminal spinner progress cmdlet. See related blog post
PowerShell function to indicate progress, using cli-spinner icons, during longer running tasks.
Write-TerminalProgress [-InputObject] <Object> [-IconSet] <Object> [[-Begin] <ScriptBlock>]
[-Process] <ScriptBlock> [[-End] <ScriptBlock>] [[-Activity] <String>] [[-CurrentStatus] <String>]
[-ReturnFullOutput]
The function utilizes ANSI Escape sequences the build a simple TUI that shows progress using cli-spinners. The function works similar to foreach-object in many other aspects.
$htArgs = @{
IconSet = 'fistBump' Process = { "Doing $_";sleep -Seconds 2 } Activity = 'Working hard' CurrentStatus = 'Status _' } 1..5 | Write-TerminalProgress @htArgs
Specifies the input objects. The function runs the script block or operation statement on each input object. The argument to this parameter is usually provided by pipeline.
Type: Object
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
The IconSet to be used for the spinner.
Type: Object
Parameter Sets: (All)
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specifies a script block that runs before this cmdlet processes any input objects.
Type: ScriptBlock
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specifies the operation that is performed on each input object. This script block is run for every object in the pipeline.
Type: ScriptBlock
Parameter Sets: (All)
Aliases:
Required: True
Position: 4
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specifies a script block that runs after this cmdlet processes all input objects. This script block is only run once for the entire pipeline.
Type: ScriptBlock
Parameter Sets: (All)
Aliases:
Required: False
Position: 5
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
A static message that describes the process.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 6
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Progress output for each iteration of the process block. "_" can be used to refer to the current object.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 7
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
{{Fill ReturnFullOutput Description}}
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False