Powershell: Delete Folder if Exists

Posted by SteveHardie | On: Apr 27 2013

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

If (Test-Path $strFolderName){
	Remove-Item $strFolderName

See Also:
Powershell: Check If File Exists
Powershell: Delete File if Exists

1 Comment

  1. acg says:

    great. how do i replace c:\temp with an enviroment variable. example %temp% or %tmp% like .bat/.cmd? thanks

Leave a comment