Using -contains


i've loaded variable $inlist=import-csv "d:\somefile.txt"

it has 4 fields server,dir,user,date. if,  if ($inlist.user -contains ($line)) , $line found.

the question how address server,dir,or date value of $inlist.user found?


something this?

$testdata=@" server,dir,user,date 1,d:\data,bob,01/01/2015 2,d:\common,mary,02/01/2015 2,d:\temp,alice,03/01/2015 1,d:\old,john,04/01/2015 "@  $testdata | out-file 'c:\temp\test.csv'  $testdata=import-csv c:\temp\test.csv $line='mary' $testdata | foreach-object{     if($_.user -contains $line){write-host $_.server,$_.dir,$_.date} } 

depends on you're going data found.


inspired carlsberg.



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

CRL Revocation always failed

0x300000d errors in Microsoft Remote Desktop client

Failed to query the results of bpa xpath