I have a custom PS Object that is something like the below:
ID Folder MyServer01 \\Server\Share\Share\MyServer01 MyServer02 \\Server\Share\Share\MyServer02
Naturally the object itself is rather large, with over 1000 entries. I need to be able to select a specific row of the object based on querying the ID.
I thought something like this would work but I'm not having much luck:
$obj | Select-Object | Where-Object ($_.ID -eq "MyServer01")
I need it to return the entire row, so the above (assuming it worked) would return:
MyServer01 \\Server\Share\Share\MyServer01
EDIT:
foreach ($mf in $Folders.Tables[0]) {
$Info = New-Object System.Object
$Info | Add-Member -Type NoteProperty -Name ID -Value $mf.ID
$Info | Add-Member -Type NoteProperty -Name Folder -Value $mf.Folder
$obj += $Info
}
Select-Objectis unnecessary/redundant. What do you mean by "I'm not having much luck"? What happens?$objcomes from? How it's assigned/created?Where-Objectfilter should be just fine. Only thing that could mess with it is if theIDhas trailing whitespace (ie"MyServer01 "). Try with-match "MyServer01"or-like "*MyServer01*"