PowerShell-在屏幕上显示输出/操作

PowerShell-在屏幕上显示输出/操作,powershell,powershell-2.0,Powershell,Powershell 2.0,有这个脚本吗 "`n" $user = Read-Host "Enter Username" write-Host "Finding" -ForegroundColor Red $filePath = "\\myserver\d$\location\$user\Profile\AppData\Roaming\app\$user" "`n" $Response = Read-Host "Do you want to delete the contents of this directory

有这个脚本吗

"`n" 
$user = Read-Host "Enter Username"
write-Host "Finding" -ForegroundColor Red
$filePath = "\\myserver\d$\location\$user\Profile\AppData\Roaming\app\$user" 
"`n" 

$Response = Read-Host "Do you want to delete the contents of this directory for '$user' ?(Y/N)"
if($Response -eq "Y"){
   get-childitem $filepath -recurse | foreach ($_) {remove-item $_.fullname}
 }else{
    Write-Host "No such user found or directory does not exist..."
}

write-Host "" 
write-Host "------------Process Complete Files Removed--------------------" -ForegroundColor magenta


Start-Sleep -s 120

我想显示被删除文件的输出/实际发生的过程。在流程完成脚本的一部分之前,有什么方法可以这样做吗?

使用
删除项上的
-Verbose
参数:

Get-ChildItem $filepath -recurse | Where {!$_.PSIsContainer} | Remove-Item -verbose

在ForEach对象循环中使用Write Progress。