Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

How to loop out selected property?

$
0
0

Hi,

how to loop out the selected input value and able to loop out the rest of the property from imported csv file?

For example, I want to look properties from just based on the sAMAccountName.

This is my scripting:

$userInfo = Import-CSV D:\info.CSV 

$name = @()
$sAMAccountName = @()

ForEach-Object {
$sAMAccountName = $userInfo.sAMAccountName

$name = $userInfo.properties
}

$inputName = Read-Host -Prompt "Input sAMAccountName"

if ($sAMAccountName -contains $inputName)
    {
    Write-Host "Users Exists"
    $Where = [array]::IndexOf($sAMAccountName, $inputName)
    Write-Host "property Name: " $Name[$Where]
    }

else 
    {
    write-host 'error: '  $Error
    }


This is what I get:



Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>