首页 > 解决方案 > Command Start-Sleep -milliseconds 50

问题描述

Playing off of someone elses script (i know nothing) is there a way to apply this sleep to a command such as "dir"? Goal: Display DIR output in typewriter effect.

$string = "The quick brown fox jumped over the lazy dog."

$string -split '' |
  ForEach-Object{
    Write-Host $_ -nonew
    Start-Sleep -milliseconds 50
   }

标签: powershelldirectorysleep

解决方案


Get-Item * | ForEach-Object { Write-Output $_; Start-Sleep -milliseconds 50 }

Implementation with dir (Get-Item in Powershell)

Take each line from the output ($_) wait for 50 milliseconds and print the line.


推荐阅读