none
Powershell script doubt RRS feed

  • Question

  • Import-Csv D:\scripts\text.csv -Delimiter "|"
        ForEach-Object {
            $Name += $_."Name"
            $Phone1 += $_."Phone"

        }

    $inputNumber = Read-Host -Prompt "Phone"
    Write-Host "$inputNumber"

    if ($Phone1 -contains $inputNumber)
      {  
    Write-Host "Customer Exists!"
      $Where = [array]::IndexOf($Phone1, $inputNumber)
        Write-Host "Customer Name: " $Name[$Where]

    }

    In this i could import the csv file but if doesnt work..Could anyone help me with comparing the phone numbers to get the matched row's name..

    Monday, April 28, 2014 3:18 AM

All replies

  • Im not sure what you want this script to do but try this and change it like you want it..

    $Numbers = Import-Csv D:\scripts\text.csv -Delimiter "|"
     
    $inputNumber = Read-Host -Prompt "Phone"
    
    Write-Host "$inputNumber"
    
    if ($Numbers -match $inputNumber) {  
        Write-Host "Customer Exists!"
        Write-Host "Customer Name: " ($Numbers | where Phone -Like $CheckNumber).name
    
    }

    Thursday, May 1, 2014 3:58 PM