Then it looks as if your PowerShell engine, on the PC where you run the script, might be running out of resources.
Perhaps the $error variable contains some more info.
Or better yet, package this in a Try-Catch construct.
Get-Process-Id$PID
Try {
Get-VirtualPortGroup
}
Catch {
Get-Process-Id$PID
$_|Select*
$_.Exception.InnerException|Select*
}
Watch the PM (private memory) consumption that is returned by the Get-Process cmdlet.