testing.ps1
function Show-Spinner { param ( [scriptblock]$ScriptBlock ) process { #Dont show the cursor $Host.UI.RawUI.CursorSize = 0 $spinner = @("-", "\", "|", "/", "-", "\", "|", "/") $i = 0 $job = Start-ThreadJob -ScriptBlock $ScriptBlock $finished = $job.State -eq "Completed" while (-not $finished) { if ($i -ne 0) { Write-Host "`b" -NoNewline } Write-Host $spinner[$i % $spinner.Length] -NoNewline $i = ($i + 1) Start-Sleep -Milliseconds 70 $finished = $job.State -eq "Completed" } $cursorPos = $Host.UI.RawUI.CursorPosition $cursorPos.Y -= 1 $Host.UI.RawUI.CursorPosition = $cursorPos } end { $result = Receive-Job -Job $job Remove-Job -Job $job $result.PSObject.Properties.Remove('RunspaceId') Write-Host "" return $result } } $MyStuff = Show-Spinner -ScriptBlock { Start-Sleep -Seconds 3 $niller = $true } Write-Host "HEJ :D" |