Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

How does -contains work?

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 03-11-2008   #1 (permalink)
Tibor Soos
Guest


 

How does -contains work?

Why is this false?

[26] PS I:\>(1,2),3 -contains (1,2)
False

I think this should be True...
--
Tibor

My System SpecsSystem Spec
Old 03-11-2008   #2 (permalink)
Tibor Soos
Guest


 

RE: How does -contains work?

Probably the same type of problem with the -eq operator:

[19] PS I:\>(1,2),3 -eq 1,2
[20] PS I:\>1,2 -eq 1,2

Both give null.
--
Tibor


"Tibor Soos" wrote:
Quote:

> Why is this false?
>
> [26] PS I:\>(1,2),3 -contains (1,2)
> False
>
> I think this should be True...
> --
> Tibor
My System SpecsSystem Spec
Old 03-11-2008   #3 (permalink)
Oisin (x0n) Grehan [MVP]
Guest


 

Re: How does -contains work?

On Mar 11, 12:08*pm, Tibor Soos <TiborS...@xxxxxx>
wrote:
Quote:

> Probably the same type of problem with the -eq operator:
>
> [19] PS I:\>(1,2),3 -eq 1,2
> [20] PS I:\>1,2 -eq 1,2
>
> Both give null.
> --
> Tibor
>
>
>
> "Tibor Soos" wrote:
Quote:

> > Why is this false?
>
Quote:

> > [26] PS I:\>(1,2),3 -contains (1,2)
> > False
>
Quote:

> > I think this should be True...
> > --
> > Tibor- Hide quoted text -
>
> - Show quoted text -
To be more accurate, both return a zero length array.

- Oisin
My System SpecsSystem Spec
Old 03-11-2008   #4 (permalink)
Tibor Soos
Guest


 

Re: How does -contains work?

But why?
--
Tibor


"Oisin (x0n) Grehan [MVP]" wrote:
Quote:

> On Mar 11, 12:08 pm, Tibor Soos <TiborS...@xxxxxx>
> wrote:
Quote:

> > Probably the same type of problem with the -eq operator:
> >
> > [19] PS I:\>(1,2),3 -eq 1,2
> > [20] PS I:\>1,2 -eq 1,2
> >
> > Both give null.
> > --
> > Tibor
> >
> >
> >
> > "Tibor Soos" wrote:
Quote:

> > > Why is this false?
> >
Quote:

> > > [26] PS I:\>(1,2),3 -contains (1,2)
> > > False
> >
Quote:

> > > I think this should be True...
> > > --
> > > Tibor- Hide quoted text -
> >
> > - Show quoted text -
>
> To be more accurate, both return a zero length array.
>
> - Oisin
>
My System SpecsSystem Spec
Old 03-11-2008   #5 (permalink)
Marco Shaw [MVP]
Guest


 

Re: How does -contains work?

Tibor Soos wrote:
Quote:

> Why is this false?
>
> [26] PS I:\>(1,2),3 -contains (1,2)
> False
>
> I think this should be True...
So, I'll assume you are trying to compare arrays of numbers?

I don't know if the comparison operators were meant to do that...

--
Microsoft MVP - Windows PowerShell
http://www.microsoft.com/mvp

PowerGadgets MVP
http://www.powergadgets.com/mvp

Blog:
http://marcoshaw.blogspot.com
My System SpecsSystem Spec
Old 03-11-2008   #6 (permalink)
ajax76
Guest


 

Re: How does -contains work?

On 12 мар, 02:08, Tibor Soos <TiborS...@xxxxxx>
wrote:
Quote:

> Probably the same type of problem with the -eq operator:
>
> [19] PS I:\>(1,2),3 -eq 1,2
> [20] PS I:\>1,2 -eq 1,2
>
> Both give null.
> --
> Tibor
>
>
>
> "Tibor Soos" wrote:
Quote:

> > Why is this false?
>
Quote:

> > [26] PS I:\>(1,2),3 -contains (1,2)
> > False
>
Quote:

> > I think this should be True...
> > --
> > Tibor- Скрыть цитируемый текст-
>
> - Показать цитируемый текст -
The "-contains" lookup solitary value in array.
You may try this:
((1,2,3),(1,2),3)|?{[string]$_ -eq '1 2'}
My System SpecsSystem Spec
Old 03-12-2008   #7 (permalink)
Tibor Soos
Guest


 

Re: How does -contains work?

"Marco Shaw [MVP]" wrote:
Quote:

> Tibor Soos wrote:
Quote:

> > Why is this false?
> >
> > [26] PS I:\>(1,2),3 -contains (1,2)
> > False
> >
> > I think this should be True...
>
> So, I'll assume you are trying to compare arrays of numbers?
>
> I don't know if the comparison operators were meant to do that...
>
> --
> Microsoft MVP - Windows PowerShell
> http://www.microsoft.com/mvp
>
> PowerGadgets MVP
> http://www.powergadgets.com/mvp
>
> Blog:
> http://marcoshaw.blogspot.com
>
Well, I think my idea would well fit into the concept of how PS manages
objects...
My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Still searching for way to get Vista search to work: Why doesn't FilterFilesWithUnknownExtensions registry key work in Vista? Celegans Vista General 11 08-31-2007 09:04 AM
Some administrator work doesn't work Rem-8 Vista General 4 05-19-2007 07:08 AM
all cd's don't work, but dvd's still work Phil Vista hardware & devices 2 05-18-2007 09:35 AM
HP LaserJet 1010 don't work in Vista since Beta2 - Advanced 1384 Printing Support drivers for XP don't work Alexey Vista print fax & scan 2 10-18-2006 07:05 PM
Will all the programs that work on xp work on vista? exciter Vista General 14 10-06-2006 11:40 PM


Update your Vista Drivers Update Your Vista Drivers Now!!

Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
╘ Designer Media 2005-2008
Page generated in 0.30247 seconds with 10 queries