有这个脚本
"`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
我希望显示正在删除的文件的输出/实际发生的过程。在进程完成脚本的一部分之前,有什么办法吗?
答案 0 :(得分:2)
使用-Verbose
上的Remove-Item
参数:
Get-ChildItem $filepath -recurse | Where {!$_.PSIsContainer} | Remove-Item -verbose