My apologies, I wasn't clear.
Is this PC attached to a domain (i.e. where user accounts of students are created elsewhere and local roaming profiles are created on whatever domain-attached devices they log on to)?
I get the impression that it's either a standalone PC or in a peer-to-peer workgroup using just local accounts. If so then it's more complicated than just automating the process of deleting local profiles older than 30 days from a scheduled task run at startup.
The doc you attached shows a manual method of deleting profiles using a local account with administrative privileges, i.e. an account in the local Administrator
s group. What mechanism would you use to create a new local account for a user if their old profile was deleted and they then needed to use the PC again?
Libraries tend to avoid all this complexity of having to create individual user accounts on shared PCs by using third-party products like Faronics'
Deep Freeze where there's a single 'standard' user account on each PC which is refreshed from a hidden image on startup. Unfortunately
Deep Freeze has become quite expensive. Microsoft used to have a freeware equivalent called
Windows SteadyState but it's never been available for Windows 10. There are, however,
alternatives to Deep Freeze.
Sorry for all the questions. Automatically deleting profiles is fairly easy. For example, from
PowerShell:
Code:
Get-WMIObject -class Win32_UserProfile | Where {(!$.Special) -and ($.ConvertToDateTime($_.LastUseTime) -lt (Get-Date).AddDays(-30))} | Remove-WmiObject
Automatically creating new profiles is not...
(EDIT: Or see this
TechNet article:
How to delete user profiles older than a specified number of days in Windows for another
PowerShell method... which still doesn't address the issue of automatic
creation of new profiles.)
Hope this helps...