October 10, 2012 at 12:37 pm
I want need to understand why the code below returns
alpha
-----
Y
Can someone explain why I don't see
alpha
-----
X
Y
Bonus points: if the last 2 lines are
$cAlphas = $Objects | select alpha | Get-Unique
$cAlphas
why do I get
alpha
-----
X
Thanks!
$Objects = @()
$Object = New-Object system.object
$Object | Add-Member -Type NoteProperty -Name alpha -value "X"
$Object | Add-Member -Type NoteProperty -Name Num -value "1"
$Objects += $Object
$Object = New-Object system.object
$Object | Add-Member -Type NoteProperty -Name alpha -value "X"
$Object | Add-Member -Type NoteProperty -Name Num -value "2"
$Objects += $Object
$Object = New-Object system.object
$Object | Add-Member -Type NoteProperty -Name alpha -value "Y"
$Object | Add-Member -Type NoteProperty -Name Num -value "1"
$Objects += $Object
$Object = New-Object system.object
$Object | Add-Member -Type NoteProperty -Name alpha -value "Y"
$Object | Add-Member -Type NoteProperty -Name Num -value "2"
$Objects += $Object
$cAlphas = $Objects | select alpha
$cAlphas | Sort-Object -Unique
October 10, 2012 at 2:46 pm
This may not be a complete answer (I don't think I'll be getting any bonus points), but I was able to get the proper output by adding -Property to the Sort.
$cAlphas | Sort-Object -Property alpha -Unique
- Jeff
October 11, 2012 at 7:56 am
SORRY: This should have been a new topic, reposting.
Hi,
I have 2 Array or ArrayList objects, with data like
$Results = New-Object system.Collections.ArrayList
$Results.Add("IMP_Trn_Project_Agent_6,User1")
$Results.Add("IMP_Trn_Project_Agent_6,User2")
$Results.Add("IMP_Trn_Project_Agent_6,User3")
$Remove = New-Object system.Collections.ArrayList
$Remove.Add("User2")
How can I efficiently remove from the first array all items containing the users in the 2nd array?
Paul
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply