PSP Plus incrementing variables incorrectly

GM All.

I've been using PSP for a while, and recently noticed this issue using version x.64 ( 5.0.1130.0).

I am looping through a number of VirtualCenters to get VM information using the script below. When I run the code below against one VirtualCenter, it works fine, however if I run it against multiple VitualCenters, it appends to the variable '$vms' referenced in the Get-View, instead of populating it with a new collection:

--------------

foreach ($VC in $ArrayVC)
{
$report =@()

$vms = get-view –viewtype VirtualMachine #Return All VM's

$VMS | %{

        $vmname = $_.Name
        $_.Config.Hardware.Device | where {$_.DeviceInfo.Label -match "Network Adapter"} | %{
        $row = "" | Select VM, MAC, Type
        $row.VM = $VMname
        $report += $row
        }
    }
}

-------------

For example, if I have 4 VirtualCenters with 1,000 VM's each, instead of each collection being set to 1,000 with each loop iteration, it keeps incrementing, i.e. 1,000, 2,000, etc.

The code works properly running within a PowerShell session, so I'm not sure why PSP would be behaving this way. Attempting to clear the variable first has no effect, I have to completely close PSP and reopen to get it clear the values.

I don't see any settings in the editor to have an impact on this, so any ideas would be helpful. Thanks.

Thanks.

Parents
No Data
Reply
  • Without a reproducible environment VirtualCenter environment this specific code would be difficult to test.

    In general, PSP pipes the saved script content to a standard Windows PowerShell session for execution just like ISE uses with any saved script. The most recent PSP versions were changed to use the PowerShell native debug context which is why they require saved scripts. The PSP editor should not influence what happens at run time. Older versions of PSP did allow you to run unsaved scripts but that is no longer the case.

    Have you tried clearing variables using the Clear-Variable cmdlet?

Children