Author Posts

November 19, 2014 at 8:37 pm

Can somebody help me with the script which can delete multiple folders (around 100 to 200 folders size approx 900 GB ) from location
(\\servername\compdata$\folersxx ) .. i am looking for something which can intitiate delete for all the folder i do not want to wait for one folder to complete then other as it will take lot of time...
Script should check foder location first if exist delete and output in log file...

Appriciate your help...!!

November 19, 2014 at 8:40 pm

...continue

forgot to mentiion.... want to delete specif folders that i have in notepad or excel these folder should get deleted rest should remain the same...

November 20, 2014 at 4:21 pm

# Remember to enter credentials that are valid for each server in your c:\servers.txt file
$credentials = Get-Credential
$servers = Get-Content c:\servers.txt
foreach ($server in $servers)
{
$scriptsFolder = Invoke-Command -ComputerName $server -Credential $credentials -ScriptBlock {Test-Path C:\Scripts}
if ($scriptsFolder -eq $true)
{
Invoke-Command -ComputerName $server -Credential $credentials -ScriptBlock {Remove-Item C:\scripts -Recurse -WhatIf}
}
}

November 20, 2014 at 4:22 pm

Remove the "whatif" when you get real serious about it!

November 20, 2014 at 6:56 pm

Thanks for speedy reply...

for mutiple servers it looks good.. I will test it out today.

... quick question
What if i have one server and multiple folders on one shared loation ( \\servername\companydata$ , under company data i have total 500 folders and i have to delete 100 folders in one go and get the output in TXT file )