Forum Discussion
Creating a way to delete all userdata via script?
Hi all,
I'm currently working on a way to figure out how to create an own image for a set of devices which will be used to lending out for exams, this is due to I don't want to have programs like Pearson Vue on our company machines, so these machines will be in a standalone image solely for lending out. After an user has used one machine I want to wipe the machine for all userdata so I can give it to the next user.
However the way I use now is to much time consuming where i wipe and install win10 manually via USB stick. I'm looking for a way were all userdata is deleted on for example log off, og can be deleted via a script in company Portal. These ways I belive i dont need to install Windows from start everytime.
Does anyone have any ideas og experiences on how to solve this?
Thanks
2 Replies
- Mmm you could create a custom powershell script that you could deploy in the company portal that sets up a scheduled task that runs as system at logoff...
And you could add something in that script like this:
$name = Get-ChildItem "c:\Users" | Sort-Object LastWriteTime -Descending | Select-Object Name, LastWriteTime -first 1
$username = $name.name
Get-CimInstance -Class Win32_UserProfile | Where-Object { $_.LocalPath.split(‘\’)[-1] -eq $username } | Remove-CimInstance
of course I did not test this idea but..... its just an idea- danidadiCopper ContributorThanks Rudy! Will def try it out