Forum Discussion
danidadi
Jun 14, 2023Copper Contributor
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 Pe...
Jun 14, 2023
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
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
- danidadiJun 30, 2023Copper ContributorThanks Rudy! Will def try it out