1
Demandez ce scriptPowerShell - Afficher sortie/action à l'écran
"`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
J'aimerais montrer la sortie des fichiers en cours de suppression/le processus prenant effectivement lieu. Toute façon de faire cela avant que le processus complète une partie du script?
Utilisez Write-Progress dans votre boucle ForEach-Object. –