$LogsPath = '\\someserver\somepath\*'
$LogsProperties = Get-ChildItem -Path $LogsPath -recurse |
Select-String -Pattern '[a-z]' |
Select-Object -Property Filename, Path, Line
$Array = @()
$LogsProperties | foreach {
$Array += $LogsProperties
}
The query above will create an array with the following values
(dashes are tabs/columns)
Filename--------------------------Path--------------------------------------------------------------Line
FName1 LName1.txt-----------\\someserver\somepath\FName1 LName1.txt-----------XXX Value
FName2 LName2.txt-----------\\someserver\somepath\FName1 LName1.txt-----------YYY Value
FName3 LName3.txt-----------\\someserver\somepath\FName1 LName1.txt-----------ZZZ Value
$Array[0]
Returns:
FName1 LName1.txt-----------\\someserver\somepath\FName1 LName1.txt-----------XXX Value
Can someone tell me how to search for the index of an element using a value
The function below doesn't work for me
$array.indexof('XXX Value')
0 <-- expected result, index of the array
and will return the error below
Method invocation failed because [System.Object[]] doesn't contain a method named 'indexof'. At line:20 char:15 + $array.indexof <<<< ('XXX Value') + CategoryInfo : InvalidOperation: (indexof:String) [], RuntimeException + FullyQualifiedErrorId : MethodNotFound