To delete a file in CMD, use the command del "filename". For folders, use rmdir /S /Q "foldername". In PowerShell, the commands are Remove-Item "filename" -Force for files and Remove-Item "foldername" -Recurse -Force for folders. The -Force and -Recurse parameters in PowerShell ensure deletion of read-only files and all contents within a folder, respectively.