how to remove directory in powershell code example

Example 1: powershell remove folder and contents

Remove-Item -LiteralPath "foldertodelete" -Force -Recurse

Example 2: powershell delete all files with specific extension in sub directories

Get-ChildItem * -Include *.csv -Recurse | Remove-Item

Example 3: powershell delete folder

Remove-Item 'D:\temp\Test Folder1'

Example 4: remove directory powershell

rmdir <directory_name>

# If you have something (files, other directories etc) in the directory you'll be asked if you want to delete those too.