When something weird happens, try running the same code in a fresh session.
Sometimes you can run into bugs, like changing a variable from $stuff to $stuff2
If code accidentally references $stuff , you might not get an error because it's not null.
that all of a sudden pcasvc doesnt dump anymore correctly,
If you run it in a new one, are you getting errors?
## A couple of notes:
- Some processes and services are not enumerable if you're not admin
- Check for
$errors. Sometimes they don't print all the info
> $error | fl * -Force
One thing that stood out is this line
$explorerPID = (Get-Process explorer).Id
It can return $null, a one number or an array of numbers