Script to delete multiple folders (Powershell)

This script will delete multiple folders and sub-folders. If the need to add other paths to delete just create more $path variables and copy and edit the IF statements.

I’ve tested this on Windows Server 2K3, Windows Server 2K8, Windows Server 2K8 R2, Windows Vista x32, Windows Vista x64, Windows 7 x32 and Windows 7 x64.

This can also be adapted you delete folders on remote systems by changing the $path to something like \\computername\C$\test or \\computername\sharename\WhateverFolderNameIs assuming your user has permissions to delete the folder.

 

Alternately, you can remove the IF statements and just use this:

 

Leave a Reply