Comments (1)
Short answer is that we don't really support comparing two collections using the comparison operators.
Long answer: the right-hand operand is treated as a singleton. That singleton object (array in your example) is compared to each item in the collection on the left-hand side. Since the singleton object is an array, the comparison becomes a reference comparison. It will only match when the right-hand object refers to the same instance of the left-hand object. Since you are comparing $a
to $a
, the -eq
operator will find matching references.
When you compare $a -eq "abc","def"
, those are two different instances, so the references don't match.
If you want to compare all the values in one array with the values in another array you have to enumerate the items yourself and compare.
from powershell-docs.
Related Issues (20)
- unauthorized access HOT 1
- 7.3 showing as supported when supported ended May 8th HOT 1
- pwsh.exe not recognized HOT 2
- red
- Mention that clean is added in powershell 7.3
- FLUTTER DOSEN'T RECOGONIZE HOT 1
- Get-SmallFiles example with PSDefaultValue attribute does not work
- Reporting Bugs Against PowerShell Cmdlets HOT 3
- Not work install in 23.10 HOT 3
- HAS MISSING INFO FROM THE GITHUB DESKTOP HOT 2
- Typo in New-FileCatalog.md - Extra contradictory word
- Get-SPOSite(Microsoft.Online.SharePoint.PowerShell) when use -Limit parameter "SharingCapability" value is returned correct, not match with the article HOT 1
- idl HOT 1
- Example 3 calling a variable that is not set and using "CimClasName" rather then "CimClassName" property
- Explain URL encoding when passing query parameters to body HOT 1
- Get-ControlPanelItem gives an error on PowerShell 7.4.2 on windows 11 home 23H2 HOT 2
- WinPS5.1 Register-PSSessionConfiguration ignores `-NoServiceRestart`
- Consider changing the term "empty null" to "enumerable null" or "null enumerable" HOT 2
- syntax error in example 16 for get-winevent doc, "<=" in filterxml HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from powershell-docs.