Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Powershell to delete listed folders from a text file

$
0
0

Hi,

I am trying to come up with a Powershell script to query a text file with a list of folders, delete the folders listed and create a log file of the deleted folders.

I am new to this, so do bare with me, this is what i have come up with so far. But it does not seems to do anything. Any ideas would be appreciated.

Thanks in advance.

*******************************************************************************************************************************

$Deleted_Users = "C:\Test\Delete\filelist.txt" 
$Home_Folders = "C:\Test\Delete"

$UserList = Import-Txt $filelist

$UserList | ForEach-Object {    
   $ID = $_.ID  
   $User_Home = $Home_Folders + "\" + $_.ID }

Remove-Item $Home_Folders | Out-File c:\Test\Delete\Deleted.txt }

*******************************************************************************************************************************


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>