$CLIENT = Get-Content "c:\Temp\computers.txt"
foreach($PC in $CLIENT){
# Testing PC connectivity
if(Test-Connection $PC -Count 1 -Quiet){
# Gathering users from c:\users
foreach($PCuser in (Get-ChildItem "\\$pc\c$\users" -Directory)){
# delete recursively
RD "\\$PC\c$\Users\$($pcuser.name)\Desktop\*.*"
RD "\\$PC\c$\Users\$($pcuser.name)\Downloads\*.*"
RD "\\$PC\c$\Users\$($pcuser.name)\Documents\*.*"
RD "\\$PC\c$\Users\$($pcuser.name)\Music\*.*"
RD "\\$PC\c$\Users\$($pcuser.name)\Pictures\*.*"
RD "\\$PC\c$\Users\$($pcuser.name)\Videos\*.*"
}
}else{
Write-Warning "$PC is offline"
}
}
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.