hashtable - Why the powershell convert my hash table into string block -
i have hashtable ($applications) looks that:
name version ---- ------- adobe flash player 19 activex 19.0.0.226 enterprise library 4.0 - may 2008 4.0.0.0 entity framework designer visual studio 2012 - enu 11.1.21009.00 fiddler 2.4.0.6 google chrome 49.0.2623.87 iis 8.0 express 8.0.1557
so i'm trying exclude applications list , i'm using:
[array]$excludeapps = "fiddler","chrome" foreach ($excludeapp in $excludeapps){ $applications = $applications -notlike "*$excludeapp*" } the result maybe filtered out exclude list not expected:
@{name=adobe flash player 19 activex; version=19.0.0.226} @{name=enterprise library 4.0 - may 2008; version=4.0.0.0} @{name=entity framework designer visual studio 2012 - enu; version=11.1.21009.00} @{name=iis 8.0 express; version=8.0.1557} i tried handle values getenumerator() , several syntax of ${applications.name} nothing worked. believe powershell detect list string.
any idea how handle this?
use select-object -match/-notmatch operator.
i.e.:
$application = $application | ? { $_.name -notmatch "fiddler" -or $_.name -notmatch "chrome"} or in loop:
[array]$excludeapps = "fiddler","chrome" foreach ($excludeapp in $excludeapps){ $applications = $applications | ? {$_.name -notmatch $excludeapp } }
Comments
Post a Comment