piercj2
Enthusiast
Enthusiast

that's really close but, if the conditions are met, i.e.  PowerState=PoweredOff and Status=Decommissioned, that entire row is copied from $bigList to $smallList.

I'm trying to include only specific columns in $smallList. e.g. VMName and PowerState or, VMName and Status

I've tried

$smallList = @($bigList.Where({$_.PowerState -match 'PoweredOff' -and $_.Status -match 'Decommissioned'}))

$smallList | select $smallList.VMname, $smallList.PowerState Export-Csv -Path c:\Temp\smallList.csv

but it fails

I've also tried

$smallList = @($bigList.Where({$_.PowerState -match 'PoweredOff' -and $_.Status -match 'Decommissioned' select $_.'VM Name', $_.'CI Status'}))

$smallList

| select $smallList.VMname, $smallList.PowerState

Export-Csv

-Path c:\Temp\smallList.csv

But that REALLY fails

Reply
0 Kudos