Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6675485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:51:42+00:00 2026-05-26T03:51:42+00:00

Question, I’d like to be able to compare a list of objects against an

  • 0

Question, I’d like to be able to compare a list of objects against an array of strings. More or less, like using the Sql ‘IN’ operator (where TableName IN(‘Table1′,’Table2′,’Table3’).

Specifically, I’m using the SMO table list, and I’d like to return only the tables by name that are contained within an array of table names.

For example:
$tablelist = @(“Address”,”Phone”, “Email”)

sl “SQLSERVER:SQL\SERVERNAME\DEFAULT\DATABASES\DATABASEName\TABLES”

$tables = gci | where{$_.Name –> wtf do I do here with the $tablelist, if this is possible?}

TIA!
B

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:51:42+00:00Added an answer on May 26, 2026 at 3:51 am

    Update:

    Seems like -in is added in v3.0. Assumed that it was there all along!

    So in v2.0, you have to use -contains or -eq:

    $tables = gci | where { $tablelist -contains  $_.Name}
    

    or

    $tables = gci | where { $tablelist -eq $_.Name}
    

    There are multiple operators that you can use:

    $a = 1,2,3
    
    1 -in $a  #True
    4 -in $a  #False
    
    $a -contains 1  #True
    $a -contains 4  #True
    
    $a -eq 1  #gives 1
    $a -eq 4  #returns nothing
    

    The -in operator is similar to what you are used to in SQL. When used with array, -eq sees if the element is present in the array and returns the element if so. So you can use it like if($a -eq 1)

    So in your case, you can do something like:

    $tables = gci | where {$_.Name -in $tablelist }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

question origin Given an unsorted array of size n containing objects with ids of
Question: How do I compile a .bat file using QtCreator? More info: specifically, I
Question Using XSLT 1.0, given a string with arbitrary characters how can I get
Question Implement a function bool chainable(vector<string> v) , which takes a set of strings
Question: Is it possible to cluster an application which is using Socket.io for WebSocket
Question: I have just wrote my first code using c# lambda expressions. It works,
Question: How do I get a byte stream that works like StringIO for Python
Question How do you modify a value in a PHP array if you do
Question edited for clarity I make an AJAX call, using the $.getJSON() method, and
Question update: I have figured out that importing JQuery (even without using it at

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.