xxxxxxxxxx
# Get the path of the folder you want to remove
$folderPath = "C:\path\to\folder"
# Check if the folder exists
if (Test-Path $folderPath) {
# Remove the folder recursively
Remove-Item -Path $folderPath -Recurse -Force
Write-Host "Folder removed successfully."
} else {
Write-Host "Folder does not exist."
}
xxxxxxxxxx
#Remove the directory without confirmation
Remove-Item -LiteralPath "foldertodelete" -Force -Recurse
#Remove the directory with confirmation
Remove-Item -Path "foldertodelete"
#without using powershell
rmdir "Path/to/directory"
xxxxxxxxxx
// to delete a folder or file with windows powershell
Remove-Item <folder-name> or <file-name>
Remove-Item Test-Folder or Test.txt