Compare SQL table to array

Welcome Forums General PowerShell Q&A Compare SQL table to array

This topic contains 1 reply, has 2 voices, and was last updated by

3 years, 3 months ago.

  • Author
  • #34246

    Topics: 5
    Replies: 7
    Points: 1
    Rank: Member

    Hi guys

    I wonder if any of you good folks can help me please?

    I have a SQL query that fills a table:

    $DataAdapter = new-object System.Data.SqlClient.SqlDataAdapter
    $DataAdapter.SelectCommand = $PrinterSelectCmd
    $dataset = new-object System.Data.Dataset
    $PrinterXmlFile = $dataset.Tables[0]

    I then also have an array that has the locally installed printer information

    $printer = Get-WmiObject Win32_Printer

    Is there a quick, easy way to compare if any of the values in $PrinterXmlFile (eg the sharename) against $Printer, if they aren't in $printer to then build a new list based on the objects that arent in $printer?

    Many thanks


  • #34263

    Topics: 13
    Replies: 4872
    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    No. You're going to need to construct custom objects from each, so that you're comparing apples to apples, in which case Compare-Object can do it.

The topic ‘Compare SQL table to array’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort