Considering you're dealing with values returned by a Win32 function, I'd have to guess that your definition of the structure that holds each value is incorrect. Most likely the definition you've used has understated the size of the struct and you've overflowed the stack which holds the information necessary the return to the ISE.
Script crshes ISE

Perez, Oscar
21
Reputation points
Good afternoon,
I downloaded the Get-NetSession.ps1 script from the TechNet Script Center Gallery, but I needed the number of open files, so I substituted SESSION_INFO_10 for SESSION_INFO_1 and defined the two extra fields. It runs and returns the open files, but it crashes ISE right after that.
Does anyone have any ideas why its doing this?
Running on a Windows 10 Enterprise Edition workstation.
Thanks.