PowerShell Script hangs when removing User Accounts

I have a Cleanup PowerShell Script to delete users that have been disabled for many months / years.

This script worked perfectly for 700+ user accounts, but it crashes / hangs when running for some random users. The problem line is below.

$PWUser = Get-PWUsersByMatch -UserName $Username 
Remove-PWUserByMatch -UserNameForItems $NewDocumentOwner -InputUsers $PWUser

In some cases, the user has no documents checked out, none copied out and is not the owner of any documents. I'm stuck as to why it could be causing the whole server to hang?

The only way I can stop the process is to restart the SQL Service.

Is there anything I can look for to see why these accounts might be hanging? 

Most take between 15 - 20 seconds regardless of the number of files. I have left the problem accounts running for a few minutes before having to restart the service. Whilst this is happening ProjectWise is unusable

Any ideas?


Parents Reply Children
No Data