Home » Uncategorized » Delete User profiles using DELPROF2

Delete User profiles using DELPROF2

Create .csv file with  column name “Computername”

$servers = import-csv C:\Temp\servers.csv
$comps = ($servers).ComputerName
$comps | %{ New-Item -ItemType Directory -Force \\$PSItem\c$\Temp; Copy-Item C:\Temp\Delprof \\$PSItem\c$\Temp\Delprof -Recurse -Verbose }

#clear even viewer

Invoke-Command -ComputerName $comps -ScriptBlock {
$Logs = Get-EventLog -List | ForEach { $_.Log }
$Logs | ForEach { Clear-EventLog -Log $_ }
}

# Run delprof2 on remote servers
$comps | %{ Start-Process cmd.exe -ArgumentList “/k c:\temp\Delprof\DelProf2.exe /c:$PSItem /ed:admin* /u” -Wait }
$comps | %{ Restart-Computer $PSItem -AsJob -Verbose }
else
{ Write-Output “Check check folder and files correctly” }

Share This:
Facebooktwitter

Leave a Reply

Your email address will not be published. Required fields are marked *

Name *
Email *
Website