Home

Powershell: Delete Folder if Exists

Posted by SteveHardie | On: Apr 27 2013

Powershell script to delete a folder or directory if it exists:

$strFolderName="c:\temp\"
If (Test-Path $strFolderName){
	Remove-Item $strFolderName
}

See Also:
Powershell: Check If File Exists
Powershell: Delete File if Exists
Test-Path
Remove-Item

Leave a comment