creating a package to delete user profiles
Published: August 30, 2022 - 1:53 PM
Good morning
I have a PowerShell command to delete user profiles except for admin accounts. However, after the task completes correctly and deletes all the specified profiles, there are errors related to "Remove-CimInstance access denied".
The package is this one:
Is there a way to convert this command to Python? Or can we eliminate PowerShell errors?
I have a PowerShell command to delete user profiles except for admin accounts. However, after the task completes correctly and deletes all the specified profiles, there are errors related to "Remove-CimInstance access denied".
The package is this one:
Code: Select all
def install():
run_powershell('Set-ExecutionPolicy Unrestricted')
run_powershell('$AccountsToKeep = @("admin","administrator","Public","default")')
run_powershell("Get-CimInstance -Class Win32_UserProfile | Where-Object { $_.LocalPath.split('\')[-1] -notin $AccountsToKeep } | Remove-CimInstance")
Is there a way to convert this command to Python? Or can we eliminate PowerShell errors?